Loading ...
Sorry, an error occurred while loading the content.
 

vim60b gtk gui OnTheSpot patch.

Expand Messages
  • Sung-Hyun Nam
    Hello, I just re-made the OnTheSpot patch against vim-6.0b. It worked fine for me. If you have any problem with the OnTheSpot patch, please test with removing
    Message 1 of 6 , Jul 16, 2000
      Hello,

      I just re-made the OnTheSpot patch against vim-6.0b.
      It worked fine for me.
      If you have any problem with the OnTheSpot patch, please test
      with removing the 'GDK_IM_PREEDIT_CALLBACKS' in multibyte.c, line 1487(?).
      Then gvim may run using OverTheSpot. Please reply your result.
      I test it with gtk+-1.2.8.

      regards,

      namsh

      diff -u -u -r1.2 gui_gtk_x11.c
      --- ./src/gui_gtk_x11.c 2000/07/17 00:34:31 1.2
      +++ ./src/gui_gtk_x11.c 2000/07/17 00:48:34
      @@ -566,6 +566,14 @@
      state = event->state;
      g_assert(len <= sizeof(string));

      +#ifdef FEAT_XIM
      + {
      + extern int xim_queue_key_press_event(GdkEvent *ev);
      + if (xim_queue_key_press_event((GdkEvent *) event))
      + return TRUE;
      + }
      +#endif
      +
      #ifdef FEAT_HANGULIN
      if (event->keyval == GDK_space && (state & GDK_SHIFT_MASK))
      {
      @@ -1108,6 +1116,14 @@
      */
      if (event->type != GDK_BUTTON_PRESS)
      return FALSE;
      +
      +#ifdef FEAT_XIM
      + {
      + extern void xim_reset(void);
      +
      + xim_reset();
      + }
      +#endif

      x = event->x;
      y = event->y;
      diff -u -u -r1.2 multibyte.c
      --- ./src/multibyte.c 2000/07/17 00:34:32 1.2
      +++ ./src/multibyte.c 2000/07/17 00:48:34
      @@ -1484,6 +1484,8 @@
      GdkIMStyle supported_style = GDK_IM_PREEDIT_NONE |
      GDK_IM_PREEDIT_NOTHING |
      GDK_IM_PREEDIT_POSITION |
      + GDK_IM_PREEDIT_CALLBACKS |
      + /* GDK_IM_STATUS_CALLBACKS | */
      GDK_IM_STATUS_AREA |
      GDK_IM_STATUS_NONE |
      GDK_IM_STATUS_NOTHING;
      @@ -1511,8 +1513,148 @@
      }
      }

      +#include <gdk/gdkx.h>
      +
      + static void
      +preedit_start_cbproc(XIC xic, XPointer client_data, XPointer call_data)
      +{
      +}
      +
      + static void
      +xim_back_delete(int n)
      +{
      + char str[3];
      +
      + str[0] = CSI;
      + str[1] = 'k';
      + str[2] = 'b';
      + while (n-- > 0)
      + add_to_input_buf(str, 3);
      +}
      +
      +static GSList *key_press_event_queue = NULL;
      +static int preedit_buf_len = 0;
      +
      + static void
      +preedit_draw_cbproc(XIC xic, XPointer client_data, XPointer call_data)
      +{
      + XIMPreeditDrawCallbackStruct *draw_data;
      + XIMText *text;
      + GdkWChar *wstr = NULL;
      + char *src;
      + GSList *event_queue;
      + extern int draw_queue_flush(void);
      +
      + draw_data = (XIMPreeditDrawCallbackStruct *) call_data;
      + text = (XIMText *) draw_data->text;
      +
      + if (draw_data->chg_length > 0)
      + {
      + xim_back_delete(draw_data->chg_length);
      + preedit_buf_len -= draw_data->chg_length;
      + }
      + if (text && (src = text->string.multi_byte))
      + {
      + int len = strlen(src);
      +
      + wstr = g_new(GdkWChar, len);
      + preedit_buf_len += gdk_mbstowcs(wstr, src, len);
      + g_free(wstr);
      + add_to_input_buf(src, len);
      + }
      + event_queue = key_press_event_queue;
      + while (event_queue)
      + {
      + GdkEvent *ev = event_queue->data;
      + gboolean *ret;
      + gtk_signal_emit_by_name((GtkObject*)gui.mainwin, "key_press_event",
      + ev, &ret);
      + gdk_event_free(ev);
      + event_queue = event_queue->next;
      + }
      + if (key_press_event_queue)
      + {
      + g_slist_free(key_press_event_queue);
      + key_press_event_queue = NULL;
      + }
      + if (gtk_main_level() > 0)
      + gtk_main_quit();
      +}
      +
      + static void
      +preedit_caret_cbproc(XIC xic, XPointer client_data, XPointer call_data)
      +{
      +}
      +
      + static void
      +preedit_done_cbproc(XIC xic, XPointer client_data, XPointer call_data)
      +{
      +}
      +
      + void
      +xim_reset(void)
      +{
      + char * text;
      +
      + if (xic)
      + {
      + text = XmbResetIC(((GdkICPrivate *)xic)->xic);
      + if (!(xim_input_style & GDK_IM_PREEDIT_CALLBACKS))
      + add_to_input_buf(text, strlen(text));
      + else
      + preedit_buf_len = 0;
      + if (text)
      + XFree(text);
      + }
      +}
      +
      + int
      +xim_queue_key_press_event(GdkEvent *ev)
      +{
      + if (preedit_buf_len <= 0)
      + return FALSE;
      +
      + key_press_event_queue = g_slist_append(key_press_event_queue,
      + gdk_event_copy(ev));
      + return TRUE;
      +}
      +
      + static void
      +preedit_callback_setup(GdkIC *ic)
      +{
      + XIC xxic;
      + XVaNestedList preedit_attr;
      + XIMCallback preedit_start_cb;
      + XIMCallback preedit_draw_cb;
      + XIMCallback preedit_caret_cb;
      + XIMCallback preedit_done_cb;
      +
      + xxic = ((GdkICPrivate*)xic)->xic;
      + preedit_start_cb.callback = (XIMProc)preedit_start_cbproc;
      + preedit_draw_cb.callback = (XIMProc)preedit_draw_cbproc;
      + preedit_caret_cb.callback = (XIMProc)preedit_caret_cbproc;
      + preedit_done_cb.callback = (XIMProc)preedit_done_cbproc;
      + preedit_attr
      + = XVaCreateNestedList (0,
      + XNPreeditStartCallback, &preedit_start_cb,
      + XNPreeditDrawCallback, &preedit_draw_cb,
      + XNPreeditCaretCallback, &preedit_caret_cb,
      + XNPreeditDoneCallback, &preedit_done_cb,
      + XNPreeditStartCallback, &preedit_start_cb,
      + 0);
      + XSetICValues (xxic, XNPreeditAttributes, preedit_attr, 0);
      + XFree(preedit_attr);
      +}
      +
      + static void
      +reset_state_setup(GdkIC *ic)
      +{
      + /* don't change the input context when we call reset */
      + XSetICValues(((GdkICPrivate*)ic)->xic, XNResetState, XIMPreserveState, 0);
      +}
      +
      void
      -xim_init()
      +xim_init(void)
      {
      xic = NULL;
      xic_attr = NULL;
      @@ -1584,6 +1726,11 @@
      attr->status_fontset = gui.fontset;
      }
      }
      + else if ((xim_input_style & GDK_IM_STATUS_MASK)
      + == GDK_IM_STATUS_CALLBACKS)
      + {
      + /* FIXME */
      + }
      #endif

      xic = gdk_ic_new(attr, attrmask);
      @@ -1595,6 +1742,9 @@
      mask = gdk_window_get_events(widget->window);
      mask |= gdk_ic_get_events(xic);
      gdk_window_set_events(widget->window, mask);
      + if (xim_input_style & GDK_IM_PREEDIT_CALLBACKS)
      + preedit_callback_setup(xic);
      + reset_state_setup(xic);
      }
      }
      }
    • Bram Moolenaar
      Sung-Hyun - ... Should I include this patch in Vim 6.0? I don t mind if it s a bit risky, as long as we will be able to solve problems later. - Bram -- f y cn
      Message 2 of 6 , Jul 17, 2000
        Sung-Hyun -

        > I just re-made the OnTheSpot patch against vim-6.0b.
        > It worked fine for me.
        > If you have any problem with the OnTheSpot patch, please test
        > with removing the 'GDK_IM_PREEDIT_CALLBACKS' in multibyte.c, line 1487(?).
        > Then gvim may run using OverTheSpot. Please reply your result.
        > I test it with gtk+-1.2.8.

        Should I include this patch in Vim 6.0? I don't mind if it's a bit risky, as
        long as we will be able to solve problems later.

        - Bram

        --
        f y cn rd ths thn y cn hv grt jb n cmptr prgrmmng

        /// Bram Moolenaar Bram@... http://www.moolenaar.net \\\
        \\\ Vim: http://www.vim.org ICCF Holland: http://iccf-holland.org ///
      • Takuhiro Nishioka
        Hi, ... I tried this patch. The OnTheSpot feature is great, I think. But it doesn t work correctly on my Japanese environment. While connecting to XIM,
        Message 3 of 6 , Jul 17, 2000
          Hi,

          Sung-Hyun Nam wrote:
          > I just re-made the OnTheSpot patch against vim-6.0b.
          > It worked fine for me.
          > If you have any problem with the OnTheSpot patch, please test
          > with removing the 'GDK_IM_PREEDIT_CALLBACKS' in multibyte.c, line 1487(?).
          > Then gvim may run using OverTheSpot. Please reply your result.
          > I test it with gtk+-1.2.8.

          I tried this patch. The OnTheSpot feature is great, I
          think. But it doesn't work correctly on my Japanese
          environment. While connecting to XIM, pressing CTRL key
          makes gvim hangs often.

          My environments:
          OS: FreeBSD 4.0-STABLE
          X: XFree86 4.0.1
          GTK: gtk+-1.2.8
          IM: kinput2 version 3
          or
          VJE-Delta 3.0 Trial

          And I'd like to suggest a feature: Coloring preediting
          texts. So that we can easily distingish what we are
          writing from what we have written.

          I wish I could implement by myself, but it's beyond me...
        • Sung-Hyun Nam
          ... Because I have no problem, I cannot help. X and gtk+ are almost same. My environments: MiziOS-1.1 (similar to RedHat). glibc-2.1.2 based XFree86 4.0.1 (CVS
          Message 4 of 6 , Jul 17, 2000
            Takuhiro Nishioka wrote:
            >
            > Sung-Hyun Nam wrote:
            > > I just re-made the OnTheSpot patch against vim-6.0b.
            > > It worked fine for me.
            > > If you have any problem with the OnTheSpot patch, please test
            > > with removing the 'GDK_IM_PREEDIT_CALLBACKS' in multibyte.c, line 1487(?).
            > > Then gvim may run using OverTheSpot. Please reply your result.
            > > I test it with gtk+-1.2.8.
            >
            > I tried this patch. The OnTheSpot feature is great, I
            > think. But it doesn't work correctly on my Japanese
            > environment. While connecting to XIM, pressing CTRL key
            > makes gvim hangs often.
            > My environments:
            > OS: FreeBSD 4.0-STABLE
            > X: XFree86 4.0.1
            > GTK: gtk+-1.2.8
            > IM: kinput2 version 3
            > or
            > VJE-Delta 3.0 Trial

            Because I have no problem, I cannot help.
            X and gtk+ are almost same. My environments:

            MiziOS-1.1 (similar to RedHat). glibc-2.1.2 based
            XFree86 4.0.1 (CVS version), gtk+-1.2.8 (CVS version).
            Ami-1.0.6

            So, Bram, vim should have a option
            (such as 'set xim_method=OverTheSpot,StatusArea')
            to include this patch though the above problem could be fixed.

            > And I'd like to suggest a feature: Coloring preediting
            > texts. So that we can easily distingish what we are
            > writing from what we have written.

            I hope also, but how can it be done in vim.
            I think when we do 'add_to_input_buf()', we also should do
            'these_char_has_underline_or_color_attribute()'
            in preedit_draw_cbproc(). Can we do?

            namsh
          • Bram Moolenaar
            ... The option should probably be used to disable input methods that don t work. ... Is this what we need? I notice GTK takes the command line arguments
            Message 5 of 6 , Jul 18, 2000
              Sung-Hyun Nam wrote:

              > So, Bram, vim should have a option
              > (such as 'set xim_method=OverTheSpot,StatusArea')
              > to include this patch though the above problem could be fixed.

              The option should probably be used to disable input methods that don't work.
              Something like:
              :set ximdisable=OverTheSpot

              Is this what we need?

              I notice GTK takes the command line arguments (gui_gtk_x11.c):
              "--xim-preedit",
              "--xim-status",
              Do these interfere somehow?

              > > And I'd like to suggest a feature: Coloring preediting
              > > texts. So that we can easily distingish what we are
              > > writing from what we have written.
              >
              > I hope also, but how can it be done in vim.
              > I think when we do 'add_to_input_buf()', we also should do
              > 'these_char_has_underline_or_color_attribute()'
              > in preedit_draw_cbproc(). Can we do?

              I'll leave this to someone who understans how XIM works...

              --
              TIM: That is not an ordinary rabbit ... 'tis the most foul cruel and
              bad-tempered thing you ever set eyes on.
              ROBIN: You tit. I soiled my armour I was so scared!
              "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

              /// Bram Moolenaar Bram@... http://www.moolenaar.net \\\
              \\\ Vim: http://www.vim.org ICCF Holland: http://iccf-holland.org ///
            • Sung-Hyun Nam
              ... No, I need also status handle, see below two options. ... Ah! I didn t notice vim support these options. User can use those options to select best method.
              Message 6 of 6 , Jul 18, 2000
                Bram Moolenaar wrote:
                >
                > Sung-Hyun Nam wrote:
                >
                > > So, Bram, vim should have a option
                > > (such as 'set xim_method=OverTheSpot,StatusArea')
                > > to include this patch though the above problem could be fixed.
                >
                > The option should probably be used to disable input methods that don't work.
                > Something like:
                > :set ximdisable=OverTheSpot
                >
                > Is this what we need?

                No, I need also status handle, see below two options.

                > I notice GTK takes the command line arguments (gui_gtk_x11.c):
                > "--xim-preedit",
                > "--xim-status",
                > Do these interfere somehow?

                Ah! I didn't notice vim support these options.
                User can use those options to select best method. But he always
                add that option (though he can use alias).
                Hmm, currently OnTheSpot patch only has a problem for some people
                and because gtk gui only support OnTheSpot, we can let user use those
                command line options if he has a problem with OnTheSpot.

                > > > And I'd like to suggest a feature: Coloring preediting
                > > > texts. So that we can easily distingish what we are
                > > > writing from what we have written.
                > >
                > > I hope also, but how can it be done in vim.
                > > I think when we do 'add_to_input_buf()', we also should do
                > > 'these_char_has_underline_or_color_attribute()'
                > > in preedit_draw_cbproc(). Can we do?
                >
                > I'll leave this to someone who understans how XIM works...

                I believe we need someone who understands how VIM works.
                XIM side is simple. Get a character from IM program and add those
                characters to input buf. At that time, I also need give a attribute to
                those characters (Mozilla has underline attr and I personally prefer
                underline).

                namsh
              Your message has been successfully submitted and would be delivered to recipients shortly.