Advertisement
Guest User

i18n-1.3.0.patch

a guest
Dec 27th, 2014
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.55 KB | None | 0 0
  1. diff -u ../org/ratpoison-1.3.0/src/actions.c ./src/actions.c
  2. --- ../org/ratpoison-1.3.0/src/actions.c 2004-05-20 14:33:47.000000000 +0900
  3. +++ ./src/actions.c 2004-06-25 03:57:53.000000000 +0900
  4. @@ -1930,7 +1930,7 @@
  5. for(i=0; license_text[i]; i++)
  6. {
  7. XDrawString (dpy, s->help_window, s->normal_gc,
  8. - x, y + defaults.font->max_bounds.ascent,
  9. + x, y + font_ascent,
  10. license_text[i], strlen (license_text[i]));
  11.  
  12. y += FONT_HEIGHT (defaults.font);
  13. @@ -1985,19 +1985,19 @@
  14. XGrabKeyboard (dpy, s->help_window, False, GrabModeSync, GrabModeAsync, CurrentTime);
  15.  
  16. XDrawString (dpy, s->help_window, s->normal_gc,
  17. - 10, y + defaults.font->max_bounds.ascent,
  18. + 10, y + font_ascent,
  19. "ratpoison key bindings", strlen ("ratpoison key bindings"));
  20.  
  21. y += FONT_HEIGHT (defaults.font) * 2;
  22.  
  23. XDrawString (dpy, s->help_window, s->normal_gc,
  24. - 10, y + defaults.font->max_bounds.ascent,
  25. + 10, y + font_ascent,
  26. "Command key: ", strlen ("Command key: "));
  27.  
  28. keysym_name = keysym_to_string (prefix_key.sym, prefix_key.state);
  29. XDrawString (dpy, s->help_window, s->normal_gc,
  30. 10 + XTextWidth (defaults.font, "Command key: ", strlen ("Command key: ")),
  31. - y + defaults.font->max_bounds.ascent,
  32. + y + font_ascent,
  33. keysym_name, strlen (keysym_name));
  34. free (keysym_name);
  35.  
  36. @@ -2012,7 +2012,7 @@
  37. keysym_name = keysym_to_string (map->actions[i].key, map->actions[i].state);
  38.  
  39. XDrawString (dpy, s->help_window, s->normal_gc,
  40. - x, y + defaults.font->max_bounds.ascent,
  41. + x, y + font_ascent,
  42. keysym_name, strlen (keysym_name));
  43.  
  44. if (XTextWidth (defaults.font, keysym_name, strlen (keysym_name)) > max_width)
  45. @@ -2023,7 +2023,7 @@
  46. else
  47. {
  48. XDrawString (dpy, s->help_window, s->normal_gc,
  49. - x, y + defaults.font->max_bounds.ascent,
  50. + x, y + font_ascent,
  51. map->actions[i].data, strlen (map->actions[i].data));
  52.  
  53. if (XTextWidth (defaults.font, map->actions[i].data, strlen (map->actions[i].data)) > max_width)
  54. @@ -2319,12 +2319,11 @@
  55. gv.function = GXcopy;
  56. gv.line_width = 1;
  57. gv.subwindow_mode = IncludeInferiors;
  58. - gv.font = defaults.font->fid;
  59. XFreeGC (dpy, s->normal_gc);
  60. s->normal_gc = XCreateGC(dpy, s->root,
  61. GCForeground | GCBackground
  62. | GCFunction | GCLineWidth
  63. - | GCSubwindowMode | GCFont, &gv);
  64. + | GCSubwindowMode, &gv);
  65. }
  66.  
  67. static void
  68. @@ -2342,7 +2341,7 @@
  69. static char *
  70. set_font (char *data)
  71. {
  72. - XFontStruct *font;
  73. + XFontSet font;
  74.  
  75. if (data == NULL)
  76. return xstrdup (defaults.font_string);
  77. @@ -2354,6 +2353,7 @@
  78. return NULL;
  79. }
  80.  
  81. + set_extents_of_fontset(font);
  82. /* Save the font as the default. */
  83. XFreeFont (dpy, defaults.font);
  84. defaults.font = font;
  85. @@ -3402,7 +3402,7 @@
  86. /* Display the frame's number inside the window. */
  87. XDrawString (dpy, wins[i], s->normal_gc,
  88. defaults.bar_x_padding,
  89. - defaults.bar_y_padding + defaults.font->max_bounds.ascent,
  90. + defaults.bar_y_padding + font_ascent,
  91. num, strlen (num));
  92.  
  93. free (num);
  94. diff -u ../org/ratpoison-1.3.0/src/bar.c ./src/bar.c
  95. --- ../org/ratpoison-1.3.0/src/bar.c 2004-02-27 16:29:37.000000000 +0900
  96. +++ ./src/bar.c 2004-06-25 03:57:53.000000000 +0900
  97. @@ -316,7 +316,7 @@
  98. {
  99. XDrawString (dpy, s->bar_window, s->normal_gc,
  100. defaults.bar_x_padding,
  101. - defaults.bar_y_padding + defaults.font->max_bounds.ascent
  102. + defaults.bar_y_padding + font_ascent
  103. + line_no * line_height,
  104. msg + start, i - start);
  105. line_no++;
  106. @@ -327,7 +327,7 @@
  107. /* Print the last line. */
  108. XDrawString (dpy, s->bar_window, s->normal_gc,
  109. defaults.bar_x_padding,
  110. - defaults.bar_y_padding + defaults.font->max_bounds.ascent
  111. + defaults.bar_y_padding + font_ascent
  112. + line_no * line_height,
  113. msg + start, strlen (msg) - start);
  114.  
  115. diff -u ../org/ratpoison-1.3.0/src/data.h ./src/data.h
  116. --- ../org/ratpoison-1.3.0/src/data.h 2004-05-20 14:31:59.000000000 +0900
  117. +++ ./src/data.h 2004-06-25 04:12:32.000000000 +0900
  118. @@ -212,7 +212,7 @@
  119. int padding_top;
  120. int padding_bottom;
  121.  
  122. - XFontStruct *font;
  123. + XFontSet font;
  124. char *font_string;
  125.  
  126. char *fgcolor_string;
  127. diff -u ../org/ratpoison-1.3.0/src/globals.c ./src/globals.c
  128. --- ../org/ratpoison-1.3.0/src/globals.c 2004-05-06 13:12:34.000000000 +0900
  129. +++ ./src/globals.c 2004-06-25 03:57:53.000000000 +0900
  130. @@ -28,6 +28,8 @@
  131. int rat_y;
  132. int rat_visible = 1; /* rat is visible by default */
  133.  
  134. +int font_ascent, font_descent, font_width;
  135. +
  136. Atom wm_name;
  137. Atom wm_state;
  138. Atom wm_change_state;
  139. diff -u ../org/ratpoison-1.3.0/src/globals.h ./src/globals.h
  140. --- ../org/ratpoison-1.3.0/src/globals.h 2004-04-19 06:33:04.000000000 +0900
  141. +++ ./src/globals.h 2004-06-25 03:57:53.000000000 +0900
  142. @@ -23,8 +23,8 @@
  143.  
  144. #include "data.h"
  145.  
  146. -#define FONT_HEIGHT(f) ((f)->max_bounds.ascent + (f)->max_bounds.descent)
  147. -#define MAX_FONT_WIDTH(f) ((f)->max_bounds.width)
  148. +#define FONT_HEIGHT(f) (font_ascent + font_descent)
  149. +#define MAX_FONT_WIDTH(f) (font_width)
  150.  
  151. #define WIN_EVENTS (StructureNotifyMask | PropertyChangeMask | ColormapChangeMask | FocusChangeMask)
  152. /* EMPTY is used when a frame doesn't contain a window, or a window
  153. @@ -63,6 +63,8 @@
  154.  
  155. extern struct rp_defaults defaults;
  156.  
  157. +extern int font_ascent, font_descent, font_width;
  158. +
  159. /* The prefix key also known as the command character under screen. */
  160. extern struct rp_key prefix_key;
  161.  
  162. diff -u ../org/ratpoison-1.3.0/src/input.c ./src/input.c
  163. --- ../org/ratpoison-1.3.0/src/input.c 2004-05-20 14:48:10.000000000 +0900
  164. +++ ./src/input.c 2004-06-25 03:57:53.000000000 +0900
  165. @@ -343,13 +343,13 @@
  166.  
  167. XDrawString (dpy, s->input_window, s->normal_gc,
  168. defaults.bar_x_padding,
  169. - defaults.bar_y_padding + defaults.font->max_bounds.ascent,
  170. + defaults.bar_y_padding + font_ascent,
  171. line->prompt,
  172. strlen (line->prompt));
  173.  
  174. XDrawString (dpy, s->input_window, s->normal_gc,
  175. defaults.bar_x_padding + prompt_width,
  176. - defaults.bar_y_padding + defaults.font->max_bounds.ascent,
  177. + defaults.bar_y_padding + font_ascent,
  178. line->buffer,
  179. line->length);
  180.  
  181. diff -u ../org/ratpoison-1.3.0/src/main.c ./src/main.c
  182. --- ../org/ratpoison-1.3.0/src/main.c 2004-06-14 14:25:16.000000000 +0900
  183. +++ ./src/main.c 2004-06-25 04:22:20.000000000 +0900
  184. @@ -454,6 +454,17 @@
  185. free (prefix);
  186. }
  187.  
  188. +void
  189. +set_extents_of_fontset(XFontSet font)
  190. +{
  191. + XFontSetExtents *extent;
  192. + extent = XExtentsOfFontSet(font);
  193. + font_ascent = extent->max_logical_extent.height * 9 / 10;
  194. + font_descent = extent->max_logical_extent.height / 5;
  195. + font_width = extent->max_logical_extent.width;
  196. +}
  197. +
  198. +
  199. static void
  200. init_defaults ()
  201. {
  202. @@ -484,6 +495,7 @@
  203. exit (EXIT_FAILURE);
  204. }
  205. defaults.font_string = xstrdup ("9x15bold");
  206. + set_extents_of_fontset(defaults.font);
  207.  
  208. defaults.fgcolor_string = xstrdup ("black");
  209. defaults.bgcolor_string = xstrdup ("white");
  210. @@ -515,7 +527,7 @@
  211. char *alt_rcfile = NULL;
  212.  
  213. myargv = argv;
  214. -
  215. + setlocale(LC_CTYPE, "");
  216. /* Parse the arguments */
  217. while (1)
  218. {
  219. @@ -564,7 +576,6 @@
  220. exit (EXIT_FAILURE);
  221. }
  222. }
  223. -
  224. if (!(dpy = XOpenDisplay (display)))
  225. {
  226. fprintf (stderr, "Can't open display\n");
  227. @@ -717,3 +728,21 @@
  228. XCloseDisplay (dpy);
  229. }
  230.  
  231. +XFontSet XLoadQueryFontSet(Display *disp, const char *fontset_name)
  232. +{
  233. + XFontSet fontset;
  234. + int missing_charset_count;
  235. + char **missing_charset_list;
  236. + char *def_string;
  237. +
  238. + fontset = XCreateFontSet(disp, fontset_name,
  239. + &missing_charset_list, &missing_charset_count,
  240. + &def_string);
  241. + if (missing_charset_count) {
  242. +#if 0
  243. + fprintf(stderr, "Missing charsets in FontSet(%s) creation.\n", fontset_name);
  244. +#endif
  245. + XFreeStringList(missing_charset_list);
  246. + }
  247. + return fontset;
  248. +}
  249. diff -u ../org/ratpoison-1.3.0/src/manage.c ./src/manage.c
  250. --- ../org/ratpoison-1.3.0/src/manage.c 2004-06-14 14:15:34.000000000 +0900
  251. +++ ./src/manage.c 2004-06-25 03:57:53.000000000 +0900
  252. @@ -218,33 +218,29 @@
  253. static char *
  254. get_wmname (Window w)
  255. {
  256. - Atom actual_type;
  257. - int actual_format;
  258. - int status;
  259. - unsigned long n;
  260. - unsigned long bytes_after;
  261. unsigned char *name = NULL;
  262. char *ret;
  263. -
  264. - status = XGetWindowProperty (dpy, w, wm_name, 0L, 100L, False,
  265. - XA_STRING, &actual_type, &actual_format,
  266. - &n, &bytes_after, &name);
  267. -
  268. - PRINT_DEBUG (("XGetWindowProperty: %d %ld %d %ld %ld '%s'\n", status, actual_type,
  269. - actual_format, n, bytes_after, name));
  270. -
  271. - if (status != Success || name == NULL)
  272. - {
  273. - PRINT_DEBUG (("I can't get the WMName.\n"));
  274. - return NULL;
  275. - }
  276. -
  277. - if (n == 0)
  278. - {
  279. - PRINT_DEBUG (("I can't get the WMName.\n"));
  280. - XFree (name);
  281. - return NULL;
  282. - }
  283. + XTextProperty text_prop;
  284. + int n;
  285. + char** cl;
  286. +
  287. + if (XGetWMName(dpy, w, &text_prop) != 0) {
  288. + if (text_prop.encoding == XA_STRING) {
  289. + name = (char *)text_prop.value;
  290. + } else {
  291. + XmbTextPropertyToTextList(dpy, &text_prop, &cl, &n);
  292. + if (cl) {
  293. + name = strdup(cl[0]);
  294. + XFreeStringList(cl);
  295. + } else {
  296. + PRINT_DEBUG (("I can't get the WMName.\n"));
  297. + return NULL;
  298. + }
  299. + }
  300. + } else {
  301. + PRINT_DEBUG (("I can't get the WMName.\n"));
  302. + return NULL;
  303. + }
  304.  
  305. PRINT_DEBUG (("WM_NAME: '%s'\n", name));
  306.  
  307. diff -u ../org/ratpoison-1.3.0/src/ratpoison.h ./src/ratpoison.h
  308. --- ../org/ratpoison-1.3.0/src/ratpoison.h 2004-02-27 16:29:37.000000000 +0900
  309. +++ ./src/ratpoison.h 2004-06-25 03:57:53.000000000 +0900
  310. @@ -30,6 +30,7 @@
  311. #include <stdio.h>
  312. #include <stdarg.h>
  313. #include <X11/Xlib.h>
  314. +#include <X11/Xlocale.h>
  315. #include <fcntl.h>
  316.  
  317. /* Some systems don't define the close-on-exec flag in fcntl.h */
  318. @@ -100,4 +101,11 @@
  319. char *xvsprintf (char *fmt, va_list ap);
  320. int str_comp (char *s1, char *s2, int len);
  321.  
  322. +#define XLoadQueryFont XLoadQueryFontSet
  323. +XFontSet XLoadQueryFontSet(Display *, const char *);
  324. +#define XFreeFont XFreeFontSet
  325. +void set_extents_of_fontset (XFontSet font);
  326. +#define XTextWidth XmbTextEscapement
  327. +#define XDrawString(d,w,gc,x,y,s,l) XmbDrawString(d,w,defaults.font,gc,x,y,s,l)
  328. +
  329. #endif /* ! _RATPOISON_H */
  330. diff -u ../org/ratpoison-1.3.0/src/screen.c ./src/screen.c
  331. --- ../org/ratpoison-1.3.0/src/screen.c 2004-02-27 18:25:24.000000000 +0900
  332. +++ ./src/screen.c 2004-06-25 03:57:53.000000000 +0900
  333. @@ -276,10 +276,9 @@
  334. gv.function = GXcopy;
  335. gv.line_width = 1;
  336. gv.subwindow_mode = IncludeInferiors;
  337. - gv.font = defaults.font->fid;
  338. s->normal_gc = XCreateGC(dpy, s->root,
  339. GCForeground | GCBackground | GCFunction
  340. - | GCLineWidth | GCSubwindowMode | GCFont,
  341. + | GCLineWidth | GCSubwindowMode,
  342. &gv);
  343.  
  344. /* Create the program bar window. */
  345. diff -u ../org/ratpoison-1.3.0/src/split.c ./src/split.c
  346. --- ../org/ratpoison-1.3.0/src/split.c 2004-02-27 18:29:36.000000000 +0900
  347. +++ ./src/split.c 2004-06-25 03:57:53.000000000 +0900
  348. @@ -942,7 +942,7 @@
  349.  
  350. XDrawString (dpy, s->frame_window, s->normal_gc,
  351. defaults.bar_x_padding,
  352. - defaults.bar_y_padding + defaults.font->max_bounds.ascent,
  353. + defaults.bar_y_padding + font_ascent,
  354. msg, strlen (msg));
  355. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement