aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorBian Jiaping2016-01-13 14:43:44 +0800
committerBian Jiaping2016-01-13 14:50:27 +0800
commit986be45cbace207f10c142dbf6fe42f223466880 (patch)
tree4cad31ee3f79012a57c1240f19cc8a96c5d6e5d5
downloadaur-986be45cbace207f10c142dbf6fe42f223466880.tar.gz
Initialize
-rw-r--r--.SRCINFO33
-rw-r--r--.gitignore4
-rw-r--r--PKGBUILD50
-rw-r--r--README.md22
-rwxr-xr-xsubl32
-rw-r--r--sublime-text-dev.install19
-rw-r--r--sublime_imfix.c264
-rw-r--r--sublime_text_3.desktop24
8 files changed, 418 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..fcea3f8128bd
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,33 @@
+# Generated by mksrcinfo v8
+# Wed Jan 13 06:43:25 UTC 2016
+pkgbase = sublime-text-dev-imfix2
+ pkgdesc = Sophisticated text editor for code, html and prose - dev build with input method support for CJK users
+ pkgver = 3.3083
+ pkgrel = 1
+ url = http://www.sublimetext.com/3
+ install = sublime-text-dev.install
+ arch = i686
+ arch = x86_64
+ license = custom
+ depends = libpng
+ depends = gtk2
+ optdepends = gksu: sudo-save support
+ provides = sublime-text-dev
+ provides = sublime-text-nightly
+ provides = sublime-text-dev-imfix
+ conflicts = sublime-text-dev
+ conflicts = sublime-text-nightly
+ conflicts = sublime-text-dev-imfix
+ source = sublime_text_3.desktop
+ source = subl3
+ source = sublime_imfix.c
+ sha256sums = f355c6bec64e962a5735d0a7d1e11ac39b5b82aacaaf23b222c0bc202e15d866
+ sha256sums = f0d3cc429aa79585fdd2f83046de5eecf48a474c07bbdb57a1655f98ee2d580c
+ sha256sums = 5903b47f7dfbf079987c566361c5735a002dcbf25d0f86de86b7dce424f36700
+ source_i686 = http://c758482.r82.cf2.rackcdn.com/sublime_text_3_build_3083_x32.tar.bz2
+ sha256sums_i686 = 89e8e2bafa041c263d2c5ffd1b8ea3c36d9727c95a3f7a6603bdf1f6c4cc3165
+ source_x86_64 = http://c758482.r82.cf2.rackcdn.com/sublime_text_3_build_3083_x64.tar.bz2
+ sha256sums_x86_64 = 4565c7f607b69ca6efa1751c739a11d42aeaf66d15987fbb9595e97e3ece14ee
+
+pkgname = sublime-text-dev-imfix2
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000000..05a9a09773b8
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+/pkg
+/src
+/*.tar.bz2
+/*.tar.xz
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..61db8fbcf403
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,50 @@
+# Maintainer: Bian Jiaping <ssbianjp@gmail.com>
+
+pkgname=sublime-text-dev-imfix2
+pkgver=3.3083
+pkgrel=1
+pkgdesc="Sophisticated text editor for code, html and prose - dev build with input method support for CJK users"
+arch=('i686' 'x86_64')
+url="http://www.sublimetext.com/3"
+license=('custom')
+depends=('libpng' 'gtk2')
+optdepends=('gksu: sudo-save support')
+conflicts=('sublime-text-dev' 'sublime-text-nightly' 'sublime-text-dev-imfix')
+provides=('sublime-text-dev' 'sublime-text-nightly' 'sublime-text-dev-imfix')
+install=sublime-text-dev.install
+
+source=('sublime_text_3.desktop' 'subl3' 'sublime_imfix.c')
+source_x86_64=("http://c758482.r82.cf2.rackcdn.com/sublime_text_3_build_${pkgver:2}_x64.tar.bz2")
+source_i686=("http://c758482.r82.cf2.rackcdn.com/sublime_text_3_build_${pkgver:2}_x32.tar.bz2")
+
+sha256sums=('f355c6bec64e962a5735d0a7d1e11ac39b5b82aacaaf23b222c0bc202e15d866'
+ 'f0d3cc429aa79585fdd2f83046de5eecf48a474c07bbdb57a1655f98ee2d580c'
+ '5903b47f7dfbf079987c566361c5735a002dcbf25d0f86de86b7dce424f36700'
+ )
+sha256sums_i686=('89e8e2bafa041c263d2c5ffd1b8ea3c36d9727c95a3f7a6603bdf1f6c4cc3165')
+sha256sums_x86_64=('4565c7f607b69ca6efa1751c739a11d42aeaf66d15987fbb9595e97e3ece14ee')
+
+build() {
+ # build imfix library
+ gcc -shared -o libsublime-imfix.so `pkg-config --libs --cflags gtk+-2.0` -fPIC sublime_imfix.c
+}
+
+package() {
+ cd "${srcdir}"
+
+ install -dm755 "${pkgdir}/opt"
+ cp --preserve=mode -r "sublime_text_3" "${pkgdir}/opt/sublime_text_3"
+
+ # Install imfix library
+ install -Dm755 libsublime-imfix.so ${pkgdir}/opt/sublime_text_3/libsublime-imfix.so
+
+ for res in 128x128 16x16 256x256 32x32 48x48; do
+ install -dm755 "${pkgdir}/usr/share/icons/hicolor/${res}/apps"
+ ln -s "/opt/sublime_text_3/Icon/${res}/sublime-text.png" "${pkgdir}/usr/share/icons/hicolor/${res}/apps/sublime-text.png"
+ done
+
+ install -dm755 "${pkgdir}/usr/share/applications"
+ install -Dm644 "sublime_text_3.desktop" "${pkgdir}/usr/share/applications/sublime_text_3.desktop"
+
+ install -Dm755 subl3 "${pkgdir}/usr/bin/subl3"
+}
diff --git a/README.md b/README.md
new file mode 100644
index 000000000000..de5507b8bcc9
--- /dev/null
+++ b/README.md
@@ -0,0 +1,22 @@
+# Sublime Text Dev Imfix
+
+Sublime text dev build with input method support for CJK users.
+
+Built on top of [sublime-text-dev][sublime-text-dev].
+
+The solution is provided by cjacker and whitequark on [sublime text forum][imfix-solution].
+
+## Installation
+
+```
+yaourt -S sublime-text-dev-imfix2
+```
+
+## Known issues
+
+* `Open in Browser` of html files not work
+* `Preview in Browser` of [Markdown Preview plugin][markdown-preview] not work
+
+[sublime-text-dev]: https://aur.archlinux.org/packages/sublime-text-dev
+[imfix-solution]: http://www.sublimetext.com/forum/viewtopic.php?f=3&t=7006&hilit=fcitx&sid=3365e98c72d98e949e44ed9dfc7a7bc2&start=20#p61143
+[markdown-preview]: https://github.com/revolunet/sublimetext-markdown-preview
diff --git a/subl3 b/subl3
new file mode 100755
index 000000000000..77a0dc1827db
--- /dev/null
+++ b/subl3
@@ -0,0 +1,2 @@
+#!/usr/bin/bash
+LD_PRELOAD=/opt/sublime_text_3/libsublime-imfix.so /opt/sublime_text_3/sublime_text "$@"
diff --git a/sublime-text-dev.install b/sublime-text-dev.install
new file mode 100644
index 000000000000..b02fe8529bd3
--- /dev/null
+++ b/sublime-text-dev.install
@@ -0,0 +1,19 @@
+post_install() {
+ # Update icon cache.
+ gtk-update-icon-cache -f '/usr/share/icons/hicolor' > /dev/null 2>&1
+
+ # Note admin after install/update on how to change th update_check setting.
+ cat << _EOF
+
+ ==> sublime-text-dev install/upgrade note:
+ ------------------------------------------------------------------------------
+ To disable in-application reminders about new Sublime Text dev versions,
+ add the following setting to your User Preferences file:
+ "update_check": false
+
+_EOF
+}
+
+post_upgrade() {
+ post_install
+}
diff --git a/sublime_imfix.c b/sublime_imfix.c
new file mode 100644
index 000000000000..cd293ffe23ef
--- /dev/null
+++ b/sublime_imfix.c
@@ -0,0 +1,264 @@
+/*
+sublime-imfix.c
+Use LD_PRELOAD to interpose some function to fix sublime input method support for linux.
+By Cjacker Huang <jianzhong.huang at i-soft.com.cn>
+By whitequark@whitequark.org
+
+How to compile:
+gcc -shared -o libsublime-imfix.so sublime_imfix.c `pkg-config --libs --cflags gtk+-2.0` -fPIC
+How to use:
+LD_PRELOAD=./libsublime-imfix.so sublime_text
+
+Changes:
+2014 06-09
+1, Fix cursor position update for sublime text 3.
+2, Combine the codes from whitequark(fix for xim immodule) and add cursor update support for XIM immodule.
+*/
+
+/*for RTLD_NEXT*/
+#define _GNU_SOURCE
+
+#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
+#include <assert.h>
+#include <dlfcn.h>
+#include <stdio.h>
+#include <string.h>
+#include <gtk/gtk.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+#ifdef VERBOSE
+#define DEBUG(fmt, ...) do { \
+ FILE* err = fopen("/tmp/libsublime-immethod-fix.log", "a"); \
+ if (err) { \
+ fprintf(err, fmt, __VA_ARGS__); \
+ fclose(err); \
+ } \
+ } while(0)
+#else
+#define DEBUG(fmt, ...)
+#endif
+
+
+typedef GdkSegment GdkRegionBox;
+
+struct _GdkRegion
+{
+ long size;
+ long numRects;
+ GdkRegionBox *rects;
+ GdkRegionBox extents;
+};
+
+GtkIMContext *local_context;
+
+
+//this func is interposed to support cursor position update.
+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 in sublime text 2
+ //And is 1 in sublime text 3.
+ //Maybe sometimes we will make a mistake, but for most of the time, it should be the caret.
+ if((rectangle->width == 2 || rectangle->width == 1) && 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);
+
+ //below is our interposed codes to save the context to local_context.
+ 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;
+ }
+ //only add this event_filter when using 'fcitx' immodule.
+ //for xim immodule, this function is as same as original from gtk2.
+ const gchar * immodule = g_getenv("GTK_IM_MODULE");
+ if(immodule && !strcmp(immodule, "fcitx")) {
+ gdk_window_add_filter (window, event_filter, context);
+ }
+}
+
+
+/*below codes is from whitequark, fix for xim immodule*/
+
+/* See gtkimcontextxim.c */
+GType gtk_type_im_context_xim = 0;
+
+#define GTK_TYPE_IM_CONTEXT_XIM (gtk_type_im_context_xim)
+#define GTK_IM_CONTEXT_XIM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_IM_CONTEXT_XIM, GtkIMContextXIM))
+#define GTK_IM_CONTEXT_XIM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_IM_CONTEXT_XIM, GtkIMContextXIMClass))
+#define GTK_IS_IM_CONTEXT_XIM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_IM_CONTEXT_XIM))
+#define GTK_IS_IM_CONTEXT_XIM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_IM_CONTEXT_XIM))
+#define GTK_IM_CONTEXT_XIM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_IM_CONTEXT_XIM, GtkIMContextXIMClass))
+
+typedef struct _GtkIMContextXIM GtkIMContextXIM;
+typedef struct _GtkIMContextXIMClass GtkIMContextXIMClass;
+
+struct _GtkIMContextXIMClass
+{
+ GtkIMContextClass parent_class;
+};
+
+typedef struct _StatusWindow StatusWindow;
+typedef struct _GtkXIMInfo GtkXIMInfo;
+
+struct _GtkIMContextXIM
+{
+ GtkIMContext object;
+
+ GtkXIMInfo *im_info;
+
+ gchar *locale;
+ gchar *mb_charset;
+
+ GdkWindow *client_window;
+ GtkWidget *client_widget;
+
+ /* The status window for this input context; we claim the
+* * status window when we are focused and have created an XIC
+* */
+ StatusWindow *status_window;
+
+ gint preedit_size;
+ gint preedit_length;
+ gunichar *preedit_chars;
+ XIMFeedback *feedbacks;
+
+ gint preedit_cursor;
+
+ XIMCallback preedit_start_callback;
+ XIMCallback preedit_done_callback;
+ XIMCallback preedit_draw_callback;
+ XIMCallback preedit_caret_callback;
+
+ XIMCallback status_start_callback;
+ XIMCallback status_done_callback;
+ XIMCallback status_draw_callback;
+
+ XIMCallback string_conversion_callback;
+
+ XIC ic;
+
+ guint filter_key_release : 1;
+ guint use_preedit : 1;
+ guint finalizing : 1;
+ guint in_toplevel : 1;
+ guint has_focus : 1;
+};
+
+static GClassInitFunc orig_gtk_im_context_xim_class_init;
+static GType (*orig_g_type_module_register_type)(GTypeModule *,
+ GType, const gchar *,
+ const GTypeInfo *, GTypeFlags);
+static gboolean (*orig_gtk_im_context_xim_filter_keypress)(GtkIMContext *context,
+ GdkEventKey *event);
+
+static gboolean
+hook_gtk_im_context_xim_filter_keypress(GtkIMContext *context, GdkEventKey *event) {
+ GtkIMContextXIM *im_context_xim = GTK_IM_CONTEXT_XIM(context);
+ if (!im_context_xim->client_window) {
+ DEBUG("im_context_xim == %p\n", im_context_xim);
+ DEBUG("event->window == %p\n", event->window);
+
+ gtk_im_context_set_client_window(context, event->window);
+ }
+
+ return orig_gtk_im_context_xim_filter_keypress(context, event);
+}
+
+static void
+hook_gtk_im_context_xim_class_init (GtkIMContextXIMClass *class) {
+ orig_gtk_im_context_xim_class_init(class, NULL); /* wat? */
+
+ GtkIMContextClass *im_context_class = GTK_IM_CONTEXT_CLASS (class);
+
+ assert(!orig_gtk_im_context_xim_filter_keypress);
+ orig_gtk_im_context_xim_filter_keypress = im_context_class->filter_keypress;
+ im_context_class->filter_keypress = hook_gtk_im_context_xim_filter_keypress;
+ DEBUG("orig_gtk_im_context_xim_filter_keypress: %p\n",
+ orig_gtk_im_context_xim_filter_keypress);
+}
+
+GType
+g_type_module_register_type (GTypeModule *module,
+ GType parent_type,
+ const gchar *type_name,
+ const GTypeInfo *type_info,
+ GTypeFlags flags) {
+ if (!orig_g_type_module_register_type) {
+ orig_g_type_module_register_type = dlsym(RTLD_NEXT, "g_type_module_register_type");
+ assert(orig_g_type_module_register_type);
+ }
+
+ if (type_name && !strcmp(type_name, "GtkIMContextXIM")) {
+ assert(!orig_gtk_im_context_xim_class_init);
+ orig_gtk_im_context_xim_class_init = type_info->class_init;
+
+ assert(sizeof(GtkIMContextXIM) == type_info->instance_size);
+
+ const GTypeInfo hook_im_context_xim_info =
+ {
+ type_info->class_size,
+ type_info->base_init,
+ type_info->base_finalize,
+ (GClassInitFunc) hook_gtk_im_context_xim_class_init,
+ type_info->class_finalize,
+ type_info->class_data,
+ type_info->instance_size,
+ type_info->n_preallocs,
+ type_info->instance_init,
+ };
+
+ DEBUG("orig_gtk_im_context_xim_class_init: %p\n", orig_gtk_im_context_xim_class_init);
+
+ gtk_type_im_context_xim =
+ orig_g_type_module_register_type(module, parent_type, type_name,
+ &hook_im_context_xim_info, flags);
+
+ return gtk_type_im_context_xim;
+ }
+
+ return orig_g_type_module_register_type(module, parent_type, type_name, type_info, flags);
+}
+
diff --git a/sublime_text_3.desktop b/sublime_text_3.desktop
new file mode 100644
index 000000000000..81c347cff1a5
--- /dev/null
+++ b/sublime_text_3.desktop
@@ -0,0 +1,24 @@
+[Desktop Entry]
+Version=1.0
+Type=Application
+Name=Sublime Text 3 Dev
+GenericName=Text Editor
+Comment=Sophisticated text editor for code, markup and prose
+Exec=subl3 %F
+Terminal=false
+MimeType=text/plain;
+Icon=sublime-text
+Categories=TextEditor;Development;
+StartupNotify=true
+StartupWMClass=subl3
+Actions=Window;Document;
+
+[Desktop Action Window]
+Name=New Window
+Exec=subl3 -n
+OnlyShowIn=Unity;
+
+[Desktop Action Document]
+Name=New File
+Exec=subl3 --command new_file
+OnlyShowIn=Unity;