From 4817cf2c78b0cb6b47aeb25cf5e77f78b4c44e3b Mon Sep 17 00:00:00 2001 From: cos Date: Thu, 13 Jun 2013 01:13:35 +0200 Subject: Please see irc transcript below. --- Log opened Sun Oct 30 16:27:53 2011 16:27 -!- Irssi: #feh: Total of 5 nicks [0 ops, 0 halfops, 0 voices, 5 normal] 16:27 -!- Irssi: Join to #feh was synced in 1 secs 16:30 < |cos|> I'm a long time feh user who recently discovered captions 16:31 < |cos|> unfortunately captions are practically useless for me since they only handle ascii :/ 16:31 < |cos|> before anyone says "patches are welcome" 16:32 < |cos|> do you know if anyone has ever tried to add functionality for non-ascii in captions? 16:32 < derf0> Nope, I don't think anyone ever tried. 16:33 < |cos|> then i'll make a half-hearted attempt (: 16:33 < derf0> But it shouldn't be too hard. Right now, feh ignores non-ascii input in caption mode. And I don't even know why, probably because there might be weird problems otherwise. 16:34 < |cos|> feh displays non-ascii characters in the filename correctly, it seems 16:34 < derf0> Yeah. 16:35 < |cos|> and if i mess with file->caption directly in the source it kind of works 16:36 < derf0> Hm, removing the isascii(keysym) in keyevents.c breaks more than it helps. 16:38 < |cos|> i guess giblib's only documentation is it's source code? 16:39 < derf0> Yeah, unfortunately. 16:39 < |cos|> just to get me started at the right end. is it wrapping imlib1 or imlib2? 16:40 < penma> imlib2 16:41 < |cos|> thanks 19:11 < |cos|> ...and i'm giving up 19:11 < |cos|> handling multibyte characters with low level X11 libraries can of course be done, but not easily 19:12 < |cos|> i guess there is a reason why libraries like GDK and such exist 19:12 < derf0> Yeah. 19:13 < derf0> Well, I'm afraid you'll have to live with feh not supporting non-ascii tags for now. At least I'd like not to add further dependencies ;) 19:14 < derf0> Unless of course someone comes up with a different method. Or something. We'll see. 19:14 < |cos|> i'll live with it (: 19:16 < |cos|> it's still the best alternative -- by far 19:17 < derf0> Glad to hear :) 19:19 < |cos|> thanks for creating/maintaining it! 20:32 < |cos|> for what it's worth, this patch kind of hacks multibyte support into feh captions http://pastebin.com/7DxcYX2B 20:32 < |cos|> it's ugly as hell, buggy and no way near complete 20:35 < |cos|> i'll probably good enough for me to use personally, but a proper implementation should of course enable normal backspacing et cetera 20:35 < |cos|> (and place the im and ic creation calls somewhere more appropriate) 20:36 < |cos|> i'm afraid i don't reckon i will put in the work to implement it cleanly :/ 20:37 < derf0> Well, your patch is a perfectly fine starting point, so thanks a lot already :) 20:37 * derf0 has saved it and may use it later on. But not today. --- src/keyevents.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/keyevents.c b/src/keyevents.c index 3c864fb..94ea920 100644 --- a/src/keyevents.c +++ b/src/keyevents.c @@ -379,7 +379,17 @@ void feh_event_handle_keypress(XEvent * ev) } kev = (XKeyEvent *) ev; - XLookupString(&ev->xkey, (char *) kbuf, sizeof(kbuf), &keysym, NULL); + XrmDatabase db = XrmGetDatabase(disp); + XIM im = XOpenIM(disp, db, "feh", "feh"); + XIC ic = XCreateIC(im, XNInputStyle, (XIMPreeditNone | XIMStatusNone), NULL); + if(ic != NULL) { + Status status; + memset(kbuf, 0, sizeof(kbuf)); + Xutf8LookupString(ic, &ev->xkey, (char *) kbuf, sizeof(kbuf), &keysym, &status); + } + XDestroyIC(ic); + XCloseIM(im); + state = kev->state & (ControlMask | ShiftMask | Mod1Mask | Mod4Mask); if (isascii(keysym)) @@ -452,6 +462,9 @@ void feh_event_handle_keypress(XEvent * ev) /* append to caption */ ESTRAPPEND_CHAR(FEH_FILE(winwid->file->data)->caption, keysym); winwidget_render_image_cached(winwid); + } else { + ESTRAPPEND(FEH_FILE(winwid->file->data)->caption, kbuf); + winwidget_render_image_cached(winwid); } break; } -- cgit v1.2.3