From 640b05d4573fce1c5e1b80ad68febab67151b66d Mon Sep 17 00:00:00 2001 From: Anton Gorenko Date: Wed, 26 Jan 2011 21:37:26 +0600 Subject: [PATCH] ui.backend.gtk: split off input methods support for ui.editors into .input-methods.editors (no more ui.editors with its dependencies in a deployed image for hello-ui); --- basis/ui/backend/gtk/gtk.factor | 31 +++++-------------- .../ui/backend/gtk/input-methods/authors.txt | 1 + .../gtk/input-methods/editors/authors.txt | 1 + .../gtk/input-methods/editors/editors.factor | 16 ++++++++++ .../gtk/input-methods/input-methods.factor | 11 +++++++ 5 files changed, 37 insertions(+), 23 deletions(-) create mode 100644 basis/ui/backend/gtk/input-methods/authors.txt create mode 100644 basis/ui/backend/gtk/input-methods/editors/authors.txt create mode 100644 basis/ui/backend/gtk/input-methods/editors/editors.factor create mode 100644 basis/ui/backend/gtk/input-methods/input-methods.factor diff --git a/basis/ui/backend/gtk/gtk.factor b/basis/ui/backend/gtk/gtk.factor index d012de8e18..378a2b56c2 100644 --- a/basis/ui/backend/gtk/gtk.factor +++ b/basis/ui/backend/gtk/gtk.factor @@ -5,9 +5,9 @@ alien.strings arrays assocs classes.struct command-line destructors gdk.ffi gdk.gl.ffi glib.ffi gobject-introspection.standard-types gobject.ffi gtk.ffi gtk.gl.ffi io.encodings.utf8 kernel libc literals locals math math.bitwise math.order math.vectors namespaces sequences -strings system threads ui ui.backend ui.backend.gtk.io ui.clipboards -ui.event-loop ui.gadgets ui.gadgets.editors ui.gadgets.private -ui.gadgets.worlds ui.gestures ui.pixel-formats +strings system threads ui ui.backend ui.backend.gtk.input-methods +ui.backend.gtk.io ui.clipboards ui.event-loop ui.gadgets +ui.gadgets.private ui.gadgets.worlds ui.gestures ui.pixel-formats ui.pixel-formats.private ui.private vocabs.loader ; IN: ui.backend.gtk @@ -240,27 +240,9 @@ CONSTANT: action-key-codes ! Input methods -GENERIC: support-input-methods? ( gadget -- ? ) -GENERIC: get-cursor-surrounding ( gadget -- text cursor-pos ) -GENERIC: delete-cursor-surrounding ( offset count gadget -- ) -GENERIC: get-cursor-loc&dim ( gadget -- loc dim ) - -M: gadget support-input-methods? drop f ; - -M: editor support-input-methods? drop t ; - -M: editor get-cursor-surrounding - dup editor-caret first2 [ swap editor-line ] dip ; - -M: editor delete-cursor-surrounding - 3drop ; - -M: editor get-cursor-loc&dim - [ caret-loc ] [ caret-dim ] bi ; - : on-retrieve-surrounding ( im-context win -- ? ) window world-focus dup support-input-methods? [ - get-cursor-surrounding [ utf8 string>alien -1 ] dip + cursor-surrounding [ utf8 string>alien -1 ] dip gtk_im_context_set_surrounding t ] [ 2drop f ] if ; @@ -272,7 +254,7 @@ M: editor get-cursor-loc&dim [ drop ] [ utf8 alien>string ] [ window ] tri* user-input ; : gadget-cursor-location ( gadget -- rectangle ) - [ screen-loc ] [ get-cursor-loc&dim ] bi [ v+ ] dip + [ screen-loc ] [ cursor-loc&dim ] bi [ v+ ] dip [ first2 [ >fixnum ] bi@ ] bi@ cairo_rectangle_int_t ; @@ -518,4 +500,7 @@ gtk-ui-backend ui-backend set-global { "ui.backend.gtk" "io.backend.unix" } "ui.backend.gtk.io.unix" require-when +{ "ui.backend.gtk" "ui.gadgets.editors" } +"ui.backend.gtk.input-methods.editors" require-when + [ "ui.tools" ] main-vocab-hook set-global diff --git a/basis/ui/backend/gtk/input-methods/authors.txt b/basis/ui/backend/gtk/input-methods/authors.txt new file mode 100644 index 0000000000..4af9fbeb0a --- /dev/null +++ b/basis/ui/backend/gtk/input-methods/authors.txt @@ -0,0 +1 @@ +Anton Gorenko diff --git a/basis/ui/backend/gtk/input-methods/editors/authors.txt b/basis/ui/backend/gtk/input-methods/editors/authors.txt new file mode 100644 index 0000000000..4af9fbeb0a --- /dev/null +++ b/basis/ui/backend/gtk/input-methods/editors/authors.txt @@ -0,0 +1 @@ +Anton Gorenko diff --git a/basis/ui/backend/gtk/input-methods/editors/editors.factor b/basis/ui/backend/gtk/input-methods/editors/editors.factor new file mode 100644 index 0000000000..2f648a4e95 --- /dev/null +++ b/basis/ui/backend/gtk/input-methods/editors/editors.factor @@ -0,0 +1,16 @@ +! Copyright (C) 2011 Anton Gorenko. +! See http://factorcode.org/license.txt for BSD license. +USING: kernel sequences ui.backend.gtk.input-methods +ui.gadgets.editors ; +IN: ui.backend.gtk.input-methods.editors + +M: editor support-input-methods? drop t ; + +M: editor cursor-surrounding + dup editor-caret first2 [ swap editor-line ] dip ; + +M: editor delete-cursor-surrounding + 3drop ; + +M: editor cursor-loc&dim + [ caret-loc ] [ caret-dim ] bi ; diff --git a/basis/ui/backend/gtk/input-methods/input-methods.factor b/basis/ui/backend/gtk/input-methods/input-methods.factor new file mode 100644 index 0000000000..1ad6cd3693 --- /dev/null +++ b/basis/ui/backend/gtk/input-methods/input-methods.factor @@ -0,0 +1,11 @@ +! Copyright (C) 2011 Anton Gorenko. +! See http://factorcode.org/license.txt for BSD license. +USING: kernel ui.gadgets ; +IN: ui.backend.gtk.input-methods + +GENERIC: support-input-methods? ( gadget -- ? ) +GENERIC: cursor-surrounding ( gadget -- text cursor-pos ) +GENERIC: delete-cursor-surrounding ( offset count gadget -- ) +GENERIC: cursor-loc&dim ( gadget -- loc dim ) + +M: gadget support-input-methods? drop f ;