From 653c964a39511dad9a8b8613ba9bdf9e1d9f4104 Mon Sep 17 00:00:00 2001 From: perqin Date: Tue, 16 Oct 2018 00:36:44 +0800 Subject: [PATCH 01/10] Update to 3.3176 --- .SRCINFO | 30 ++++++ .gitignore | 4 + LICENSE | 3 + PKGBUILD | 51 ++++++++++ subl | 2 + sublime-imfix.c | 263 ++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 353 insertions(+) create mode 100644 .SRCINFO create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 PKGBUILD create mode 100755 subl create mode 100644 sublime-imfix.c diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 0000000..65b65fd --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,30 @@ +pkgbase = sublime-text-3-imfix + pkgdesc = Sophisticated text editor for code, markup and prose - Stable build with input method support for CJK users + pkgver = 3.3176 + pkgrel = 1 + url = https://www.sublimetext.com/3 + arch = x86_64 + license = custom + depends = libpng + depends = gtk2 + provides = sublime-text + provides = sublime-text-dev + provides = sublime-text-nightly + provides = sublime-text-dev-imfix + provides = sublime-text-dev-imfix2 + conflicts = sublime-text + conflicts = sublime-text-dev + conflicts = sublime-text-nightly + conflicts = sublime-text-dev-imfix + conflicts = sublime-text-dev-imfix2 + source = https://download.sublimetext.com/sublime_text_3_build_3176_x64.tar.bz2 + source = sublime-imfix.c + source = subl + source = LICENSE + sha256sums = 74f17c1aec4ddec9d4d4c39f5aec0414a4755d407a05efa571e8892e0b9cf732 + sha256sums = 05c08fc144151713e25ebb528c2a86ef5aaf3afa3e20b79302faefdbb7158f12 + sha256sums = 00ab76aff168a0dcccec861610985e3695da10e6f95ce1fa399f5747b4d5af5b + sha256sums = 8e4c48469bf3f35d0c0904e770c4e307d4965a8931e839c01c5765498a19cf01 + +pkgname = sublime-text-3-imfix + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2f39e2f --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/*.tar.bz2 +/*.pkg.tar.xz +/pkg +/src diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3e2f842 --- /dev/null +++ b/LICENSE @@ -0,0 +1,3 @@ +Sublime Text may be downloaded and evaluated for free, however a license must be purchased for continued use. +Licenses are per-user, rather than per-machine, so you can enjoy Sublime Text on as many computers and operating systems as you wish with your license. +For more information, please visit https://www.sublimetext.com/buy diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..07a8654 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,51 @@ +# Maintainer: perqin + +pkgname=sublime-text-3-imfix +pkgver=3.3176 +pkgrel=1 +pkgdesc='Sophisticated text editor for code, markup and prose - Stable build with input method support for CJK users' +arch=('x86_64') +url='https://www.sublimetext.com/3' +license=('custom') +depends=('libpng' 'gtk2') +conflicts=('sublime-text' 'sublime-text-dev' 'sublime-text-nightly' 'sublime-text-dev-imfix' 'sublime-text-dev-imfix2') +provides=('sublime-text' 'sublime-text-dev' 'sublime-text-nightly' 'sublime-text-dev-imfix' 'sublime-text-dev-imfix2') +source=( + "https://download.sublimetext.com/sublime_text_3_build_${pkgver:2}_x64.tar.bz2" + 'sublime-imfix.c' + 'subl' + 'LICENSE' +) +sha256sums=( + '74f17c1aec4ddec9d4d4c39f5aec0414a4755d407a05efa571e8892e0b9cf732' + '05c08fc144151713e25ebb528c2a86ef5aaf3afa3e20b79302faefdbb7158f12' + '00ab76aff168a0dcccec861610985e3695da10e6f95ce1fa399f5747b4d5af5b' + '8e4c48469bf3f35d0c0904e770c4e307d4965a8931e839c01c5765498a19cf01' +) + +build() { + # Build imfix library + gcc -shared -o libsublime-imfix.so sublime-imfix.c `pkg-config --libs --cflags gtk+-2.0` -fPIC +} + +package() { + cd "${srcdir}" + # Install sublime text 3 + 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 + # Install icons + 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 desktop entry and executable + install -dm755 "${pkgdir}/usr/share/applications" + install -Dm644 "sublime_text_3/sublime_text.desktop" "${pkgdir}/usr/share/applications/sublime_text.desktop" + sed -i 's#/opt/sublime_text/sublime_text#subl#g' "${pkgdir}/usr/share/applications/sublime_text.desktop" + install -Dm755 subl "${pkgdir}/usr/bin/subl" + # Install license file + install -d "${pkgdir}/usr/share/licenses/${pkgname}" + install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" +} diff --git a/subl b/subl new file mode 100755 index 0000000..ff9bf52 --- /dev/null +++ b/subl @@ -0,0 +1,2 @@ +#!/bin/bash +LD_PRELOAD=/opt/sublime_text_3/libsublime-imfix.so /opt/sublime_text_3/sublime_text "$@" \ No newline at end of file diff --git a/sublime-imfix.c b/sublime-imfix.c new file mode 100644 index 0000000..9a90f1f --- /dev/null +++ b/sublime-imfix.c @@ -0,0 +1,263 @@ +/* +sublime-imfix.c +Use LD_PRELOAD to interpose some function to fix sublime input method support for linux. +By Cjacker Huang +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 +#include +#include +#include +#include +#include +#include +#include +#include + +#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); +} From de7ff47d183a09eefc7ccad4f179850409d8a336 Mon Sep 17 00:00:00 2001 From: perqin Date: Sun, 17 Mar 2019 12:07:01 +0800 Subject: [PATCH 02/10] Update to 3.3200 --- PKGBUILD | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index 07a8654..c4a32a5 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,7 +1,7 @@ # Maintainer: perqin pkgname=sublime-text-3-imfix -pkgver=3.3176 +pkgver=3.3200 pkgrel=1 pkgdesc='Sophisticated text editor for code, markup and prose - Stable build with input method support for CJK users' arch=('x86_64') @@ -17,7 +17,7 @@ source=( 'LICENSE' ) sha256sums=( - '74f17c1aec4ddec9d4d4c39f5aec0414a4755d407a05efa571e8892e0b9cf732' + 'b9d5297c65bd14a8ba3394e74dbd9a5013b3fed5a5a2f8f5120d2cec40614fbd' '05c08fc144151713e25ebb528c2a86ef5aaf3afa3e20b79302faefdbb7158f12' '00ab76aff168a0dcccec861610985e3695da10e6f95ce1fa399f5747b4d5af5b' '8e4c48469bf3f35d0c0904e770c4e307d4965a8931e839c01c5765498a19cf01' From ac6aae16c65a88086520e3be61724f3ed783a4ea Mon Sep 17 00:00:00 2001 From: perqin Date: Sun, 17 Mar 2019 12:09:15 +0800 Subject: [PATCH 03/10] Update to 3.3200 (Fix .SRCINFO) --- .SRCINFO | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.SRCINFO b/.SRCINFO index 65b65fd..0500a44 100644 --- a/.SRCINFO +++ b/.SRCINFO @@ -1,6 +1,6 @@ pkgbase = sublime-text-3-imfix pkgdesc = Sophisticated text editor for code, markup and prose - Stable build with input method support for CJK users - pkgver = 3.3176 + pkgver = 3.3200 pkgrel = 1 url = https://www.sublimetext.com/3 arch = x86_64 @@ -17,11 +17,11 @@ pkgbase = sublime-text-3-imfix conflicts = sublime-text-nightly conflicts = sublime-text-dev-imfix conflicts = sublime-text-dev-imfix2 - source = https://download.sublimetext.com/sublime_text_3_build_3176_x64.tar.bz2 + source = https://download.sublimetext.com/sublime_text_3_build_3200_x64.tar.bz2 source = sublime-imfix.c source = subl source = LICENSE - sha256sums = 74f17c1aec4ddec9d4d4c39f5aec0414a4755d407a05efa571e8892e0b9cf732 + sha256sums = b9d5297c65bd14a8ba3394e74dbd9a5013b3fed5a5a2f8f5120d2cec40614fbd sha256sums = 05c08fc144151713e25ebb528c2a86ef5aaf3afa3e20b79302faefdbb7158f12 sha256sums = 00ab76aff168a0dcccec861610985e3695da10e6f95ce1fa399f5747b4d5af5b sha256sums = 8e4c48469bf3f35d0c0904e770c4e307d4965a8931e839c01c5765498a19cf01 From e1914b9809f464d2ad133009c7cd14da4ab618c2 Mon Sep 17 00:00:00 2001 From: perqin Date: Mon, 18 Mar 2019 00:31:11 +0800 Subject: [PATCH 04/10] Remove unnecessary imfix --- .SRCINFO | 6 +- PKGBUILD | 16 +-- subl | 2 - sublime-imfix.c | 263 ------------------------------------------------ 4 files changed, 4 insertions(+), 283 deletions(-) delete mode 100755 subl delete mode 100644 sublime-imfix.c diff --git a/.SRCINFO b/.SRCINFO index 0500a44..94025cd 100644 --- a/.SRCINFO +++ b/.SRCINFO @@ -1,7 +1,7 @@ pkgbase = sublime-text-3-imfix pkgdesc = Sophisticated text editor for code, markup and prose - Stable build with input method support for CJK users pkgver = 3.3200 - pkgrel = 1 + pkgrel = 2 url = https://www.sublimetext.com/3 arch = x86_64 license = custom @@ -18,12 +18,8 @@ pkgbase = sublime-text-3-imfix conflicts = sublime-text-dev-imfix conflicts = sublime-text-dev-imfix2 source = https://download.sublimetext.com/sublime_text_3_build_3200_x64.tar.bz2 - source = sublime-imfix.c - source = subl source = LICENSE sha256sums = b9d5297c65bd14a8ba3394e74dbd9a5013b3fed5a5a2f8f5120d2cec40614fbd - sha256sums = 05c08fc144151713e25ebb528c2a86ef5aaf3afa3e20b79302faefdbb7158f12 - sha256sums = 00ab76aff168a0dcccec861610985e3695da10e6f95ce1fa399f5747b4d5af5b sha256sums = 8e4c48469bf3f35d0c0904e770c4e307d4965a8931e839c01c5765498a19cf01 pkgname = sublime-text-3-imfix diff --git a/PKGBUILD b/PKGBUILD index c4a32a5..2afb904 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -2,7 +2,7 @@ pkgname=sublime-text-3-imfix pkgver=3.3200 -pkgrel=1 +pkgrel=2 pkgdesc='Sophisticated text editor for code, markup and prose - Stable build with input method support for CJK users' arch=('x86_64') url='https://www.sublimetext.com/3' @@ -12,29 +12,18 @@ conflicts=('sublime-text' 'sublime-text-dev' 'sublime-text-nightly' 'sublime-tex provides=('sublime-text' 'sublime-text-dev' 'sublime-text-nightly' 'sublime-text-dev-imfix' 'sublime-text-dev-imfix2') source=( "https://download.sublimetext.com/sublime_text_3_build_${pkgver:2}_x64.tar.bz2" - 'sublime-imfix.c' - 'subl' 'LICENSE' ) sha256sums=( 'b9d5297c65bd14a8ba3394e74dbd9a5013b3fed5a5a2f8f5120d2cec40614fbd' - '05c08fc144151713e25ebb528c2a86ef5aaf3afa3e20b79302faefdbb7158f12' - '00ab76aff168a0dcccec861610985e3695da10e6f95ce1fa399f5747b4d5af5b' '8e4c48469bf3f35d0c0904e770c4e307d4965a8931e839c01c5765498a19cf01' ) -build() { - # Build imfix library - gcc -shared -o libsublime-imfix.so sublime-imfix.c `pkg-config --libs --cflags gtk+-2.0` -fPIC -} - package() { cd "${srcdir}" # Install sublime text 3 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 # Install icons for res in 128x128 16x16 256x256 32x32 48x48; do install -dm755 "${pkgdir}/usr/share/icons/hicolor/${res}/apps" @@ -44,7 +33,8 @@ package() { install -dm755 "${pkgdir}/usr/share/applications" install -Dm644 "sublime_text_3/sublime_text.desktop" "${pkgdir}/usr/share/applications/sublime_text.desktop" sed -i 's#/opt/sublime_text/sublime_text#subl#g' "${pkgdir}/usr/share/applications/sublime_text.desktop" - install -Dm755 subl "${pkgdir}/usr/bin/subl" + install -dm755 "${pkgdir}/usr/bin" + ln -s "/opt/sublime_text_3/sublime_text" "${pkgdir}/usr/bin/subl" # Install license file install -d "${pkgdir}/usr/share/licenses/${pkgname}" install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" diff --git a/subl b/subl deleted file mode 100755 index ff9bf52..0000000 --- a/subl +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -LD_PRELOAD=/opt/sublime_text_3/libsublime-imfix.so /opt/sublime_text_3/sublime_text "$@" \ No newline at end of file diff --git a/sublime-imfix.c b/sublime-imfix.c deleted file mode 100644 index 9a90f1f..0000000 --- a/sublime-imfix.c +++ /dev/null @@ -1,263 +0,0 @@ -/* -sublime-imfix.c -Use LD_PRELOAD to interpose some function to fix sublime input method support for linux. -By Cjacker Huang -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 -#include -#include -#include -#include -#include -#include -#include -#include - -#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); -} From ccbdc5859ea9defa2e8c56f57e5454fd330c267d Mon Sep 17 00:00:00 2001 From: perqin Date: Tue, 9 Apr 2019 22:56:00 +0800 Subject: [PATCH 05/10] Update to 3.3207 --- .SRCINFO | 8 ++++---- PKGBUILD | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.SRCINFO b/.SRCINFO index 94025cd..fd24a30 100644 --- a/.SRCINFO +++ b/.SRCINFO @@ -1,7 +1,7 @@ pkgbase = sublime-text-3-imfix pkgdesc = Sophisticated text editor for code, markup and prose - Stable build with input method support for CJK users - pkgver = 3.3200 - pkgrel = 2 + pkgver = 3.3207 + pkgrel = 1 url = https://www.sublimetext.com/3 arch = x86_64 license = custom @@ -17,9 +17,9 @@ pkgbase = sublime-text-3-imfix conflicts = sublime-text-nightly conflicts = sublime-text-dev-imfix conflicts = sublime-text-dev-imfix2 - source = https://download.sublimetext.com/sublime_text_3_build_3200_x64.tar.bz2 + source = https://download.sublimetext.com/sublime_text_3_build_3207_x64.tar.bz2 source = LICENSE - sha256sums = b9d5297c65bd14a8ba3394e74dbd9a5013b3fed5a5a2f8f5120d2cec40614fbd + sha256sums = acb64f1de024a0f004888096afa101051e48d96c7a3e7fe96e11312d524938c4 sha256sums = 8e4c48469bf3f35d0c0904e770c4e307d4965a8931e839c01c5765498a19cf01 pkgname = sublime-text-3-imfix diff --git a/PKGBUILD b/PKGBUILD index 2afb904..f262881 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,8 +1,8 @@ # Maintainer: perqin pkgname=sublime-text-3-imfix -pkgver=3.3200 -pkgrel=2 +pkgver=3.3207 +pkgrel=1 pkgdesc='Sophisticated text editor for code, markup and prose - Stable build with input method support for CJK users' arch=('x86_64') url='https://www.sublimetext.com/3' @@ -15,7 +15,7 @@ source=( 'LICENSE' ) sha256sums=( - 'b9d5297c65bd14a8ba3394e74dbd9a5013b3fed5a5a2f8f5120d2cec40614fbd' + 'acb64f1de024a0f004888096afa101051e48d96c7a3e7fe96e11312d524938c4' '8e4c48469bf3f35d0c0904e770c4e307d4965a8931e839c01c5765498a19cf01' ) From 5afd86ac7fee6a6e1b3d92dd5829298ec9319248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Marcos?= Date: Wed, 13 Nov 2019 11:32:43 -0300 Subject: [PATCH 06/10] Updating version to 3211 and changing maintainer --- PKGBUILD | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index f262881..92b610b 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,7 +1,7 @@ -# Maintainer: perqin +# Maintainer: marcospb19 pkgname=sublime-text-3-imfix -pkgver=3.3207 +pkgver=3.3211 pkgrel=1 pkgdesc='Sophisticated text editor for code, markup and prose - Stable build with input method support for CJK users' arch=('x86_64') From 46c432f447f0db9848a17cad2990f1bb4ae995ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Marcos?= Date: Wed, 13 Nov 2019 11:46:08 -0300 Subject: [PATCH 07/10] Fixing last commit --- .SRCINFO | 6 +++--- PKGBUILD | 8 +++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.SRCINFO b/.SRCINFO index fd24a30..1185994 100644 --- a/.SRCINFO +++ b/.SRCINFO @@ -1,6 +1,6 @@ pkgbase = sublime-text-3-imfix pkgdesc = Sophisticated text editor for code, markup and prose - Stable build with input method support for CJK users - pkgver = 3.3207 + pkgver = 3.3211 pkgrel = 1 url = https://www.sublimetext.com/3 arch = x86_64 @@ -17,9 +17,9 @@ pkgbase = sublime-text-3-imfix conflicts = sublime-text-nightly conflicts = sublime-text-dev-imfix conflicts = sublime-text-dev-imfix2 - source = https://download.sublimetext.com/sublime_text_3_build_3207_x64.tar.bz2 + source = https://download.sublimetext.com/sublime_text_3_build_3211_x64.tar.bz2 source = LICENSE - sha256sums = acb64f1de024a0f004888096afa101051e48d96c7a3e7fe96e11312d524938c4 + sha256sums = 0b3c8ca5e6df376c3c24a4b9ac2e3b391333f73b229bc6e87d0b4a5f636d74ee sha256sums = 8e4c48469bf3f35d0c0904e770c4e307d4965a8931e839c01c5765498a19cf01 pkgname = sublime-text-3-imfix diff --git a/PKGBUILD b/PKGBUILD index 92b610b..67cab9d 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -2,7 +2,7 @@ pkgname=sublime-text-3-imfix pkgver=3.3211 -pkgrel=1 +pkgrel=2 pkgdesc='Sophisticated text editor for code, markup and prose - Stable build with input method support for CJK users' arch=('x86_64') url='https://www.sublimetext.com/3' @@ -14,10 +14,8 @@ source=( "https://download.sublimetext.com/sublime_text_3_build_${pkgver:2}_x64.tar.bz2" 'LICENSE' ) -sha256sums=( - 'acb64f1de024a0f004888096afa101051e48d96c7a3e7fe96e11312d524938c4' - '8e4c48469bf3f35d0c0904e770c4e307d4965a8931e839c01c5765498a19cf01' -) +sha256sums=('0b3c8ca5e6df376c3c24a4b9ac2e3b391333f73b229bc6e87d0b4a5f636d74ee' + '8e4c48469bf3f35d0c0904e770c4e307d4965a8931e839c01c5765498a19cf01') package() { cd "${srcdir}" From 65321dcaa8885506f14a8fc96e4c78e4430b9e8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Marcos?= Date: Wed, 13 Nov 2019 12:13:38 -0300 Subject: [PATCH 08/10] Changed package description size --- .SRCINFO | 4 ++-- PKGBUILD | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.SRCINFO b/.SRCINFO index 1185994..cc11883 100644 --- a/.SRCINFO +++ b/.SRCINFO @@ -1,7 +1,7 @@ pkgbase = sublime-text-3-imfix - pkgdesc = Sophisticated text editor for code, markup and prose - Stable build with input method support for CJK users + pkgdesc = Sophisticated text editor for code, html and prose - Stable build with support for CJK pkgver = 3.3211 - pkgrel = 1 + pkgrel = 2 url = https://www.sublimetext.com/3 arch = x86_64 license = custom diff --git a/PKGBUILD b/PKGBUILD index 67cab9d..ec77952 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -3,7 +3,7 @@ pkgname=sublime-text-3-imfix pkgver=3.3211 pkgrel=2 -pkgdesc='Sophisticated text editor for code, markup and prose - Stable build with input method support for CJK users' +pkgdesc="Sophisticated text editor for code, html and prose - Stable build with support for CJK" arch=('x86_64') url='https://www.sublimetext.com/3' license=('custom') @@ -19,20 +19,24 @@ sha256sums=('0b3c8ca5e6df376c3c24a4b9ac2e3b391333f73b229bc6e87d0b4a5f636d74ee' package() { cd "${srcdir}" + # Install sublime text 3 install -dm755 "${pkgdir}/opt" cp --preserve=mode -r "sublime_text_3" "${pkgdir}/opt/sublime_text_3" + # Install icons 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 desktop entry and executable install -dm755 "${pkgdir}/usr/share/applications" install -Dm644 "sublime_text_3/sublime_text.desktop" "${pkgdir}/usr/share/applications/sublime_text.desktop" sed -i 's#/opt/sublime_text/sublime_text#subl#g' "${pkgdir}/usr/share/applications/sublime_text.desktop" install -dm755 "${pkgdir}/usr/bin" ln -s "/opt/sublime_text_3/sublime_text" "${pkgdir}/usr/bin/subl" + # Install license file install -d "${pkgdir}/usr/share/licenses/${pkgname}" install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" From 490414b64a122c3c87a434f9341879deba1b34bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20M=2E=20Bezerra?= Date: Sun, 13 Sep 2020 10:49:21 -0300 Subject: [PATCH 09/10] Renamed package to `sublime-text-3` --- .SRCINFO | 24 +++++++++++------------- LICENSE | 14 ++++++++++++-- PKGBUILD | 22 ++++++++++++++++------ 3 files changed, 39 insertions(+), 21 deletions(-) diff --git a/.SRCINFO b/.SRCINFO index cc11883..c7e4295 100644 --- a/.SRCINFO +++ b/.SRCINFO @@ -1,26 +1,24 @@ -pkgbase = sublime-text-3-imfix - pkgdesc = Sophisticated text editor for code, html and prose - Stable build with support for CJK +pkgbase = sublime-text-3 + pkgdesc = Sophisticated text editor for code, html and prose - stable build pkgver = 3.3211 - pkgrel = 2 + pkgrel = 1 url = https://www.sublimetext.com/3 arch = x86_64 license = custom depends = libpng depends = gtk2 provides = sublime-text - provides = sublime-text-dev - provides = sublime-text-nightly - provides = sublime-text-dev-imfix - provides = sublime-text-dev-imfix2 - conflicts = sublime-text - conflicts = sublime-text-dev + provides = sublime + conflicts = sublime-text-4-dev + conflicts = sublime-text-3-imfix + conflicts = sublime-text-imfix conflicts = sublime-text-nightly - conflicts = sublime-text-dev-imfix - conflicts = sublime-text-dev-imfix2 + conflicts = sublime-text-dev + conflicts = sublime-text2 source = https://download.sublimetext.com/sublime_text_3_build_3211_x64.tar.bz2 source = LICENSE sha256sums = 0b3c8ca5e6df376c3c24a4b9ac2e3b391333f73b229bc6e87d0b4a5f636d74ee - sha256sums = 8e4c48469bf3f35d0c0904e770c4e307d4965a8931e839c01c5765498a19cf01 + sha256sums = 339dbd1b6ae3e699809afcdd6c690299e6fa0d385aa2ef658a52d336a3f8107f -pkgname = sublime-text-3-imfix +pkgname = sublime-text-3 diff --git a/LICENSE b/LICENSE index 3e2f842..981842a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,3 +1,13 @@ -Sublime Text may be downloaded and evaluated for free, however a license must be purchased for continued use. -Licenses are per-user, rather than per-machine, so you can enjoy Sublime Text on as many computers and operating systems as you wish with your license. +Maintainer note: +Sublime Text is free to use, if you want access to the newer builds, with the package +`sublime-text-4-dev` or `sublime-text-dev`, you'll need a paid license. + +Buying a license also supports the development of the editor. + +--- + +Sublime Text may be downloaded and evaluated for free, however a license must be purchased for +continued use. Licenses are per-user, rather than per-machine, so you can enjoy Sublime Text on as +many computers and operating systems as you wish with your license. + For more information, please visit https://www.sublimetext.com/buy diff --git a/PKGBUILD b/PKGBUILD index ec77952..411ba05 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,21 +1,31 @@ # Maintainer: marcospb19 -pkgname=sublime-text-3-imfix +pkgname=sublime-text-3 pkgver=3.3211 -pkgrel=2 -pkgdesc="Sophisticated text editor for code, html and prose - Stable build with support for CJK" +pkgrel=1 +pkgdesc="Sophisticated text editor for code, html and prose - stable build" arch=('x86_64') url='https://www.sublimetext.com/3' license=('custom') depends=('libpng' 'gtk2') -conflicts=('sublime-text' 'sublime-text-dev' 'sublime-text-nightly' 'sublime-text-dev-imfix' 'sublime-text-dev-imfix2') -provides=('sublime-text' 'sublime-text-dev' 'sublime-text-nightly' 'sublime-text-dev-imfix' 'sublime-text-dev-imfix2') + +replaces=('sublime-text-3-imfix') + +conflicts=('sublime-text-4-dev' + 'sublime-text-3-imfix' + 'sublime-text-imfix' + 'sublime-text-nightly' + 'sublime-text-dev' + 'sublime-text2') + +provides=('sublime-text' 'sublime') + source=( "https://download.sublimetext.com/sublime_text_3_build_${pkgver:2}_x64.tar.bz2" 'LICENSE' ) sha256sums=('0b3c8ca5e6df376c3c24a4b9ac2e3b391333f73b229bc6e87d0b4a5f636d74ee' - '8e4c48469bf3f35d0c0904e770c4e307d4965a8931e839c01c5765498a19cf01') + '339dbd1b6ae3e699809afcdd6c690299e6fa0d385aa2ef658a52d336a3f8107f') package() { cd "${srcdir}" From 43b10975f352ea4425d2d3b5e83066e635806259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20M=2E=20Bezerra?= Date: Sun, 18 Jul 2021 21:45:58 -0300 Subject: [PATCH 10/10] Removing "sublime" from "provides" --- .SRCINFO | 4 ++-- PKGBUILD | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.SRCINFO b/.SRCINFO index c7e4295..addfb1f 100644 --- a/.SRCINFO +++ b/.SRCINFO @@ -8,17 +8,17 @@ pkgbase = sublime-text-3 depends = libpng depends = gtk2 provides = sublime-text - provides = sublime conflicts = sublime-text-4-dev + conflicts = sublime-text-4 conflicts = sublime-text-3-imfix conflicts = sublime-text-imfix conflicts = sublime-text-nightly conflicts = sublime-text-dev conflicts = sublime-text2 + replaces = sublime-text-3-imfix source = https://download.sublimetext.com/sublime_text_3_build_3211_x64.tar.bz2 source = LICENSE sha256sums = 0b3c8ca5e6df376c3c24a4b9ac2e3b391333f73b229bc6e87d0b4a5f636d74ee sha256sums = 339dbd1b6ae3e699809afcdd6c690299e6fa0d385aa2ef658a52d336a3f8107f pkgname = sublime-text-3 - diff --git a/PKGBUILD b/PKGBUILD index 411ba05..a3c3ca6 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -12,13 +12,14 @@ depends=('libpng' 'gtk2') replaces=('sublime-text-3-imfix') conflicts=('sublime-text-4-dev' + 'sublime-text-4' 'sublime-text-3-imfix' 'sublime-text-imfix' 'sublime-text-nightly' 'sublime-text-dev' 'sublime-text2') -provides=('sublime-text' 'sublime') +provides=('sublime-text') source=( "https://download.sublimetext.com/sublime_text_3_build_${pkgver:2}_x64.tar.bz2"