-
儲存下述程式碼為 sublime-imfix.c 檔案
/* sublime-imfix.c Use LD_PRELOAD to interpose some function to fix sublime input method support for linux. By Cjacker Huang gcc -shared -o libsublime-imfix.so sublime-imfix.c `pkg-config --libs --cflags gtk+-2.0` -fPIC LD_PRELOAD=./libsublime-imfix.so subl */ #include <gtk/gtk.h> #include <gdk/gdkx.h> typedef GdkSegment GdkRegionBox; struct _GdkRegion { long size; long numRects; GdkRegionBox *rects; GdkRegionBox extents; }; GtkIMContext *local_context; void gdk_region_get_clipbox (const GdkRegion *region, GdkRectangle *rectangle) { g_return_if_fail (region != NULL); g_return_if_fail (rectangle != NULL); rectangle->x = region->extents.x1; rectangle->y = region->extents.y1; rectangle->width = region->extents.x2 - region->extents.x1; rectangle->height = region->extents.y2 - region->extents.y1; GdkRectangle rect; rect.x = rectangle->x; rect.y = rectangle->y; rect.width = 0; rect.height = rectangle->height; //The caret width is 2; //Maybe sometimes we will make a mistake, but for most of the time, it should be the caret. if(rectangle->width == 2 && GTK_IS_IM_CONTEXT(local_context)) { gtk_im_context_set_cursor_location(local_context, rectangle); } } //this is needed, for example, if you input something in file dialog and return back the edit area //context will lost, so here we set it again. static GdkFilterReturn event_filter (GdkXEvent *xevent, GdkEvent *event, gpointer im_context) { XEvent *xev = (XEvent *)xevent; if(xev->type == KeyRelease && GTK_IS_IM_CONTEXT(im_context)) { GdkWindow * win = g_object_get_data(G_OBJECT(im_context),"window"); if(GDK_IS_WINDOW(win)) gtk_im_context_set_client_window(im_context, win); } return GDK_FILTER_CONTINUE; } void gtk_im_context_set_client_window (GtkIMContext *context, GdkWindow *window) { GtkIMContextClass *klass; g_return_if_fail (GTK_IS_IM_CONTEXT (context)); klass = GTK_IM_CONTEXT_GET_CLASS (context); if (klass->set_client_window) klass->set_client_window (context, window); if(!GDK_IS_WINDOW (window)) return; g_object_set_data(G_OBJECT(context),"window",window); int width = gdk_window_get_width(window); int height = gdk_window_get_height(window); if(width != 0 && height !=0) { gtk_im_context_focus_in(context); local_context = context; } gdk_window_add_filter (window, event_filter, context); }
-
安裝C/C++的編譯環境和gtk,libgtk2.0-dev
sudo apt-get install build-essential sudo apt-get install libgtk2.0-dev
-
編譯共享內庫
gcc -shared -o libsublime-imfix.so sublime-imfix.c `pkg-config --libs --cflags gtk+-2.0` -fPIC
-
設定 LD_PRELOAD 並啟動 Sublime Text
LD_PRELOAD=./libsublime-imfix.so subl
-
修改 /usr/share/applications/sublime_text.desktop 為
[Desktop Entry] [...] Exec=env LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so /opt/sublime_text/sublime_text %F [...] [Desktop Action Window] [...] Exec=env LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so /opt/sublime_text/sublime_text -n [...] [Desktop Action Document] [...] Exec=env LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so /opt/sublime_text/sublime_text --command new_file [...]
不要忘了把 libsublime-imfix.so 放到 /opt/sublime_text/ 中
-
修改 /usr/bin/subl 為
#!/bin/sh export LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text "$@"
Linux下sublime text中文輸入問題
相關文章
- 解決ubuntu下sublime無法輸入中文問題Ubuntu
- Ubuntu安裝sublime Text 3並配置可以輸入中文Ubuntu
- Sublime Text 3 中文亂碼問題的解決
- Sublime Text 3下安裝Emmet的問題
- sublime text最新註冊碼 「sublime text中文破解版下載」相容最新macos14Mac
- git bash輸入中文問題Git
- Sublime Text2 Svn設定問題
- Sublime Text 4 Dev中文破解版+Sublime Text 4 Dev啟用碼dev
- linux下的中文輸入法Linux
- rn ios 下某些版本不能輸入中文問題iOS
- Linux Ubuntu 20.04 LTS 解決無法輸入中文 輸入法問題LinuxUbuntu
- Ubuntu下解決Eclipse無法輸入中文問題UbuntuEclipse
- sublime text mac版實施輸入處理程式的技巧Mac
- [linux]解決wayland協議下 google-chrome 無法輸入中文問題Linux協議GoChrome
- sublime text 註冊碼漢化下載+sublime text 破解安裝教程
- Linux下中文包、中文輸入法的安裝Linux
- 允許Sublime編輯器在Ubuntu上輸入中文Ubuntu
- ubuntu 安裝fcitx中文簡繁體 以及sublime 可輸入中文Ubuntu
- Sublime Text3安裝包時出現的問題
- 9 個最佳的 Sublime Text 主題
- linux系統編碼問題:vi不能輸入中文,ssh遠端連線終端不能輸入中文,中文顯示亂碼等Linux
- Ubuntu下搜狗輸入法無法輸入中文Ubuntu
- Sublime Text 3 下載安裝及配置
- 解決Ubuntu 18.04中文輸入法的問題Ubuntu
- Sublime Text全程指南
- Sublime Text 4 Dev中文破解版+啟用金鑰dev
- 前端程式碼編輯:Sublime Text 4 Dev 中文mac版前端devMac
- linux 下 android studio 不能輸入中文記錄LinuxAndroid
- Sublime Text入門級教程:快捷鍵大合集~
- linux設定中文輸入法Linux
- Ubuntu 版本的 Sublime 升級後無法輸入中文解決方案Ubuntu
- ubuntu下安裝中文輸入法Ubuntu
- Qt 二級選單欄 中文無法輸入問題QT
- jquery ui autocomplete輸入中文不自動完成的問題jQueryUI
- sublime text for Mac註冊啟用 sublime text4註冊碼Mac
- Windows下使用Sublime text3快速編輯Linux檔案,寫ShellWindowsLinux
- Sublime Text 4.0 Mac版Mac
- Sublime Text 簡明教程