]> git.pld-linux.org Git - packages/dml.git/blob - dml-utf8.patch
- added the input_utf8.patch
[packages/dml.git] / dml-utf8.patch
1 --- dml-0.1.6.new/src/slang.c.old       2007-10-04 22:03:19.000000000 +0200
2 +++ dml-0.1.6.new/src/slang.c   2007-10-04 23:47:06.000000000 +0200
3 @@ -34,6 +34,7 @@
4  char *pi_conf_file = "/etc/dml.conf";
5  int pi_screen_height, pi_screen_width;
6  int pi_poor_man_frames = 0;
7 +int pi_utf8;
8  
9  struct optiondesc {
10         char *element_name;
11 @@ -152,11 +153,10 @@
12         while (*s && n--) {
13                 if (*s == '_' && s[1]) {
14                         pi_color(c2);
15 -                       pi_putch(*++s);
16 +                       s = pi_putch_utf8(++s);
17                         pi_color(c1);
18 -                       s++;
19                 } else
20 -                       pi_putch(*s++);
21 +                       s = pi_putch_utf8(s);
22         }
23  
24         pi_color(c1);
25 @@ -171,11 +171,10 @@
26         while (*s && n--) {
27                 if (*s == '_' && s[1]) {
28                         pi_color(c2);
29 -                       pi_putch(*++s);
30 +                       s = pi_putch_utf8(++s);
31                         pi_color(c1);
32 -                       s++;
33                 } else
34 -                       pi_putch(*s++);
35 +                       s = pi_putch_utf8(s);
36         }
37         
38         pi_color(c1);
39 @@ -193,6 +192,7 @@
40  
41  void pi_init()
42  {
43 +       SLutf8_enable(pi_utf8);
44         SLtt_get_terminfo();
45         if (SLkp_init() == -1)
46                 pi_die("Unable to initialize SLkp.");
47 @@ -252,6 +252,17 @@
48         SLsmg_write_char((unsigned)c & 0xff);
49  }
50  
51 +unsigned char *pi_putch_utf8(unsigned char *c)
52 +{
53 +       if (pi_utf8) {
54 +               SLsmg_write_nstring(c, 1);
55 +               return SLutf8_skip_char(c, c + 7);
56 +       } else {
57 +               pi_putch(*c);
58 +               return ++c;
59 +       }
60 +}
61 +
62  void pi_addstr(const char *c)
63  {
64         SLsmg_write_string((char*)c);
65 --- dml-0.1.6.new/src/main.c.old        2007-10-04 23:36:10.000000000 +0200
66 +++ dml-0.1.6.new/src/main.c    2007-10-04 23:39:06.000000000 +0200
67 @@ -14,12 +14,15 @@
68  #include "phash.h"
69  #include <unistd.h>
70  #include <fcntl.h>
71 +#include <langinfo.h>
72 +#include <locale.h>
73  #include <string.h>
74  #include <stdio.h>
75  #include <stdlib.h>
76  
77  static char *progie;
78  static int out_fd;
79 +extern int pi_utf8;
80  
81  static void usage(int err, char *name)
82  {
83 @@ -149,6 +152,8 @@
84         int r, i;
85         char *tmp;
86  
87 +       setlocale(LC_ALL, "");
88 +       pi_utf8 = !strcmp(nl_langinfo(CODESET), "UTF-8");
89         parse_options(argc, argv);
90  
91         /* this is to allow Shift+PgUp to look at displayed error
92 --- dml-0.1.6.new/src/pi.h.old  2007-10-04 23:49:16.000000000 +0200
93 +++ dml-0.1.6.new/src/pi.h      2007-10-04 22:52:59.000000000 +0200
94 @@ -229,6 +229,7 @@
95  void pi_goto(int x, int y);
96  void pi_frame(int x, int y, int w, int h);
97  void pi_putch(int c);
98 +unsigned char *pi_putch_utf8(unsigned char *c);
99  void pi_addstr(const char *c);
100  void pi_addstrn(const char *c, int n);
101  void pi_addstrn_fill(const char *c, int n);
This page took 0.088482 seconds and 3 git commands to generate.