[关闭]
@mritd 2015-12-15T13:28:30.000000Z 字数 3227 阅读 1578

Ubuntu鼓捣

Linux Ubuntu


Flatabulous主题

- 主题地址 Flatabulous

Sublime3

  1. Andrew Weber
  2. Single User License
  3. EA7E-855605
  4. 813A03DD 5E4AD9E6 6C0EEB94 BC99798F
  5. 942194A6 02396E98 E62C9979 4BB979FE
  6. 91424C9D A45400BF F6747D88 2FB88078
  7. 90F5CC94 1CDC92DC 8457107A F151657B
  8. 1D22E383 A997F016 42397640 33F41CFC
  9. E1D0AE85 A0BBD039 0E9C8D55 E1B89D5D
  10. 5CDB7036 E56DE1C0 EFCC0840 650CD3A6
  11. B98FC99C 8FAC73EE D2B95564 DF450523

使用中文输入法

  1. sudo zypper install build-essential libgtk2.0-dev ##opensuse
  2. sudo apt-get install build-essential libgtk2.0-dev ##ubuntu
  1. #复制一下代码,保存为 sublime-imfix.c
  2. /*
  3. sublime-imfix.c
  4. */
  5. #include <gtk/gtk.h>
  6. #include <gdk/gdkx.h>
  7. typedef GdkSegment GdkRegionBox;
  8. struct _GdkRegion
  9. {
  10. long size;
  11. long numRects;
  12. GdkRegionBox *rects;
  13. GdkRegionBox extents;
  14. };
  15. GtkIMContext *local_context;
  16. void gdk_region_get_clipbox (const GdkRegion *region, GdkRectangle *rectangle)
  17. {
  18. g_return_if_fail (region != NULL);
  19. g_return_if_fail (rectangle != NULL);
  20. rectangle->x = region->extents.x1;
  21. rectangle->y = region->extents.y1;
  22. rectangle->width = region->extents.x2 - region->extents.x1;
  23. rectangle->height = region->extents.y2 - region->extents.y1;
  24. GdkRectangle rect;
  25. rect.x = rectangle->x;
  26. rect.y = rectangle->y;
  27. rect.width = 0;
  28. rect.height = rectangle->height;
  29. //The caret width is 2;
  30. //Maybe sometimes we will make a mistake, but for most of the time, it should be the caret.
  31. if(rectangle->width == 2 && GTK_IS_IM_CONTEXT(local_context)) {
  32. gtk_im_context_set_cursor_location(local_context, rectangle);
  33. }
  34. }
  35. //this is needed, for example, if you input something in file dialog and return back the edit area
  36. //context will lost, so here we set it again.
  37. static GdkFilterReturn event_filter (GdkXEvent *xevent, GdkEvent *event, gpointer im_context)
  38. {
  39. XEvent *xev = (XEvent *)xevent;
  40. if(xev->type == KeyRelease && GTK_IS_IM_CONTEXT(im_context)) {
  41. GdkWindow * win = g_object_get_data(G_OBJECT(im_context),"window");
  42. if(GDK_IS_WINDOW(win))
  43. gtk_im_context_set_client_window(im_context, win);
  44. }
  45. return GDK_FILTER_CONTINUE;
  46. }
  47. void gtk_im_context_set_client_window (GtkIMContext *context, GdkWindow *window)
  48. {
  49. GtkIMContextClass *klass;
  50. g_return_if_fail (GTK_IS_IM_CONTEXT (context));
  51. klass = GTK_IM_CONTEXT_GET_CLASS (context);
  52. if (klass->set_client_window)
  53. klass->set_client_window (context, window);
  54. if(!GDK_IS_WINDOW (window))
  55. return;
  56. g_object_set_data(G_OBJECT(context),"window",window);
  57. int width = gdk_window_get_width(window);
  58. int height = gdk_window_get_height(window);
  59. if(width != 0 && height !=0) {
  60. gtk_im_context_focus_in(context);
  61. local_context = context;
  62. }
  63. gdk_window_add_filter (window, event_filter, context);
  64. }
  1. gcc -shared -o libsublime-imfix.so sublime_imfix.c `pkg-config --libs --cflags gtk+-2.0` -fPIC
  1. sudo mv libsublime-imfix.so /opt/sublime_text/
  1. sudo gedit /usr/bin/subl
  1. #!/bin/sh
  2. LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so
  3. exec /opt/sublime_text/sublime_text "$@"
  1. #[Desktop Entry]
  2. Exec=bash -c "LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text %F"
  3. #[Desktop Action Window]
  4. Exec=bash -c "LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text -n"
  5. #[Desktop Action Document]
  6. Exec=bash -c "LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text --command new_file"
  1. sudo cp /usr/share/applications/sublime_text.desktop /opt/sublime_text/
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注