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

XIM input status in vim6.0

Expand Messages
  • Steven Mueller
    Hello, I recently started using the 6.0 dev builds of Vim and have found that the new OnTheSpot preedit type (for the GTK GUI) is quite nice. However, I cannot
    Message 1 of 6 , Apr 19, 2001
    • 0 Attachment
      Hello,

      I recently started using the 6.0 dev builds of Vim and have found that
      the new OnTheSpot preedit type (for the GTK GUI) is quite nice.
      However, I cannot find a way to see whethere I am currently in
      conversion mode or not. It's nice not having the extra line taken up
      by a near useless status area as in vim5.7, but it's somewhat
      disconcerting to not have a visual indication of what input mode I'm
      currently typing in.

      I saw discusion on this list about similar things, but I guess nothing
      ever came of it. I also don't see any mention of it in the TODO list
      included with vim60ab. So here are my suggestions for good visual
      indications:

      When in multibyte input mode (shift-space or Kanji with my setup), the
      cursor could be a different color, a flag could appear in the status
      line, or a small window containing the characteristic Hiragana 'a' (or
      whatever is appropriate for the language) could pop up (this is what
      Mozilla does). Perhaps it would also be handy to have a vim global
      variable containing the state of the input mode (such as
      v:ximconversion=0 or 1). Or there could be an additional hint
      provided via the 'showmode' option, e.g.: -- INSERT (XIM) --

      A good means to determine whether a preedit string has been set or not
      is also needed. In mozilla, characters that have not been set are
      underlined in red. I seem to recall this idea having been mentioned
      earlier on this list.

      If anyone is working on such a thing, I'd be happy to hear about it.
      Sorry if I'm just missing something obvious, it which case a helpful
      pointer in the right direction would be appreciated. Thanks!

      Steve

      --
      Steven Mueller
      diffusor@...
    • Bram Moolenaar
      ... I agree that this would be a good idea. I have been trying making multi-byte input simpler, but since I don t use it myself and don t have support for it
      Message 2 of 6 , Apr 20, 2001
      • 0 Attachment
        Steven Mueller wrote:

        > I recently started using the 6.0 dev builds of Vim and have found that
        > the new OnTheSpot preedit type (for the GTK GUI) is quite nice.
        > However, I cannot find a way to see whethere I am currently in
        > conversion mode or not. It's nice not having the extra line taken up
        > by a near useless status area as in vim5.7, but it's somewhat
        > disconcerting to not have a visual indication of what input mode I'm
        > currently typing in.
        >
        > I saw discusion on this list about similar things, but I guess nothing
        > ever came of it. I also don't see any mention of it in the TODO list
        > included with vim60ab. So here are my suggestions for good visual
        > indications:
        >
        > When in multibyte input mode (shift-space or Kanji with my setup), the
        > cursor could be a different color, a flag could appear in the status
        > line, or a small window containing the characteristic Hiragana 'a' (or
        > whatever is appropriate for the language) could pop up (this is what
        > Mozilla does). Perhaps it would also be handy to have a vim global
        > variable containing the state of the input mode (such as
        > v:ximconversion=0 or 1). Or there could be an additional hint
        > provided via the 'showmode' option, e.g.: -- INSERT (XIM) --
        >
        > A good means to determine whether a preedit string has been set or not
        > is also needed. In mozilla, characters that have not been set are
        > underlined in red. I seem to recall this idea having been mentioned
        > earlier on this list.
        >
        > If anyone is working on such a thing, I'd be happy to hear about it.
        > Sorry if I'm just missing something obvious, it which case a helpful
        > pointer in the right direction would be appreciated. Thanks!

        I agree that this would be a good idea. I have been trying making multi-byte
        input simpler, but since I don't use it myself and don't have support for it
        on my system, I can't really do much for it. I suspect the current
        implementation has a few flaws, resulting from an attempt to automatically
        switch XIM on only when it's needed.

        I hope someone who does know about XIM can look into this. If changing the
        cursor color or shape would be a good solution, this could be added to
        'guicursor'. I could do that part. It could perhaps be done similar to how
        it works for language mappings. Would someone use XIM and language mappings
        at the same time? If not, then we could use the cursor highlighting for
        language mapping for XIM as well.

        --
        hundred-and-one symptoms of being an internet addict:
        263. You have more e-mail addresses than shorts.

        /// Bram Moolenaar -- Bram@... -- http://www.moolenaar.net \\\
        ((( Creator of Vim - http://www.vim.org -- ftp://ftp.vim.org/pub/vim )))
        \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///
      • Steven Mueller
        I decided to look into setting up a vim variable v:preediting (probably not the best of names...). Getting this working wasn t difficult, but I can t seem to
        Message 3 of 6 , Apr 20, 2001
        • 0 Attachment
          I decided to look into setting up a vim variable v:preediting
          (probably not the best of names...). Getting this working wasn't
          difficult, but I can't seem to get the status line to refresh when
          preedit mode is activated or deactivated. I've tried various
          functions, but this is the first time I've actually done anything with
          the Vim code so I don't really know what I'm doing. My .vimrc
          includes something to the tune of:

          function! FlagPreed()
          if v:preediting
          return "[¤¢]"
          else
          return ''
          endif
          endfunction

          if exists("v:preediting")
          set stl=%{FlagPreed()}%3n[%Y]%f\ %([%R%H%W]%)%=\ %2*%{Ifelse(&columns>100,strftime('%a\ %m/%d\ %T'),strftime('%a%m%d\ %H%M%S'))}%*%7(#%o:%)%2B[%03b]%4l/%L.%2c-%-3(%v%)%4P
          endif

          As you can see from the patch below, I've put the functionality in
          into the previously empty preedit callbacks. I'm not sure if this is
          the right way to do it, but it was the easiest for me to find and
          seems to suit my purpose. When the msg() calls are uncommented, those
          messages are printed at the time that I hit shift-space to enter into
          or exit from preediting mode. However, the status line does not
          update until I type something.

          Bram: how does this patch look to you? If you could point me in the
          right direction for getting the status line to refresh properly, I'd
          be greatly appreciative. I'm also open to suggestions on the name of
          the added v:variable. I don't know if I'll be able to get very far on
          any of the other suggestions I made, but I'll look into the cursor
          change possibility.

          Steve

          --- vim60ab/src/eval.c Mon Apr 16 10:52:11 2001
          +++ vim60ab-work/src/eval.c Thu Apr 19 21:48:37 2001
          @@ -170,6 +170,7 @@
          {"foldstart", sizeof("foldstart") - 1, NULL, VAR_NUMBER, VV_RO},
          {"foldend", sizeof("foldend") - 1, NULL, VAR_NUMBER, VV_RO},
          {"folddashes", sizeof("folddashes") - 1, NULL, VAR_STRING, VV_RO},
          + {"preediting", sizeof("preediting") -1, NULL, VAR_NUMBER, VV_RO},
          };

          static int eval0 __ARGS((char_u *arg, VAR retvar, char_u **nextcmd, int evaluate));
          --- vim60ab/src/mbyte.c Mon Apr 16 05:23:56 2001
          +++ vim60ab-work/src/mbyte.c Thu Apr 19 23:22:47 2001
          @@ -2925,6 +2925,13 @@
          static void
          preedit_start_cbproc(XIC xic, XPointer client_data, XPointer call_data)
          {
          + //msg("preedit_start_cbproc");
          + set_vim_var_nr(VV_PREEDITING, 1);
          +#ifdef FEAT_WINDOWS
          + status_redraw_all();
          + redraw_statuslines();
          + redraw_later(VALID);
          +#endif
          }

          static void
          @@ -3037,12 +3044,20 @@
          static void
          preedit_caret_cbproc(XIC xic, XPointer client_data, XPointer call_data)
          {
          + msg("preedit_caret_cbproc");
          }

          /*ARGSUSED*/
          static void
          preedit_done_cbproc(XIC xic, XPointer client_data, XPointer call_data)
          {
          + //msg("preedit_done_cbproc");
          + set_vim_var_nr(VV_PREEDITING, 0);
          +#ifdef FEAT_WINDOWS
          + status_redraw_all();
          + redraw_statuslines();
          + redraw_later(VALID);
          +#endif
          }

          void
          @@ -3194,6 +3209,7 @@
          == (int)GDK_IM_STATUS_CALLBACKS)
          {
          /* FIXME */
          + printf("in FIXME land\n");
          }
          #endif

          --- vim60ab/src/vim.h Sat Apr 14 13:20:35 2001
          +++ vim60ab-work/src/vim.h Thu Apr 19 21:48:52 2001
          @@ -1275,7 +1275,8 @@
          #define VV_FOLDSTART 21
          #define VV_FOLDEND 22
          #define VV_FOLDDASHES 23
          -#define VV_LEN 24 /* number of v: vars */
          +#define VV_PREEDITING 24
          +#define VV_LEN 25 /* number of v: vars */

          #ifdef FEAT_CLIPBOARD


          --
          Steven Mueller
          diffusor@...
        • Bram Moolenaar
          ... Thanks for looking into this. I m not sure if using a v: variable for this is the best choice, but we can think about that later. You seem to be calling
          Message 4 of 6 , Apr 20, 2001
          • 0 Attachment
            Steven Mueller wrote:

            > I decided to look into setting up a vim variable v:preediting
            > (probably not the best of names...). Getting this working wasn't
            > difficult, but I can't seem to get the status line to refresh when
            > preedit mode is activated or deactivated.

            Thanks for looking into this. I'm not sure if using a v: variable for this is
            the best choice, but we can think about that later.

            You seem to be calling all the right functions. Perhaps it's a matter of
            calling out_flush() to get the text onto the screen? That might be needed,
            since Vim is waiting for characters and the functions are callbacks, thus we
            don't go through the normal loop that updates the screen.

            > Bram: how does this patch look to you? If you could point me in the
            > right direction for getting the status line to refresh properly, I'd
            > be greatly appreciative. I'm also open to suggestions on the name of
            > the added v:variable. I don't know if I'll be able to get very far on
            > any of the other suggestions I made, but I'll look into the cursor
            > change possibility.

            I think that setting 'statusline' to be able to see the XIM mode is a bit
            complicated for most people. But when this works we could find a simpler way.
            Either by adding it to the default status line, or showing it in another way.

            --
            Ten bugs in the hand is better than one as yet undetected.

            /// Bram Moolenaar -- Bram@... -- http://www.moolenaar.net \\\
            ((( Creator of Vim - http://www.vim.org -- ftp://ftp.vim.org/pub/vim )))
            \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///
          • Nam SungHyun
            ... How about like this? Regards, namsh diff -u -p -r1.4 mbyte.c ... +++ ./mbyte.c 21 Apr 2001 00:29:38 -0000 @@ -2264,6 +2264,7 @@ static int
            Message 5 of 6 , Apr 20, 2001
            • 0 Attachment
              Bram Moolenaar wrote:
              >
              > Steven Mueller wrote:
              >
              > > I decided to look into setting up a vim variable v:preediting
              > > (probably not the best of names...). Getting this working wasn't
              > > difficult, but I can't seem to get the status line to refresh when
              > > preedit mode is activated or deactivated.
              >
              > Thanks for looking into this. I'm not sure if using a v: variable for
              > this is the best choice, but we can think about that later.

              How about like this?

              Regards,

              namsh

              diff -u -p -r1.4 mbyte.c
              --- ./mbyte.c 17 Apr 2001 00:42:33 -0000 1.4
              +++ ./mbyte.c 21 Apr 2001 00:29:38 -0000
              @@ -2264,6 +2264,7 @@ static int status_area_enabled = TRUE;
              static int xim_input_style;
              static gboolean use_status_area = 0;
              #endif
              +int xim_preediting = 0;

              void
              xim_set_focus(int focus)
              @@ -2925,6 +2926,12 @@ xim_decide_input_style()
              static void
              preedit_start_cbproc(XIC xic, XPointer client_data, XPointer call_data)
              {
              + xim_preediting = TRUE;
              + if (showmode())
              + {
              + setcursor();
              + out_flush();
              + }
              }

              static void
              @@ -3043,6 +3050,12 @@ preedit_caret_cbproc(XIC xic, XPointer c
              static void
              preedit_done_cbproc(XIC xic, XPointer client_data, XPointer call_data)
              {
              + xim_preediting = FALSE;
              + if (showmode())
              + {
              + setcursor();
              + out_flush();
              + }
              }

              void
              diff -u -p -r1.20.2.1 screen.c
              --- ./screen.c 18 Apr 2001 06:25:24 -0000 1.20.2.1
              +++ ./screen.c 21 Apr 2001 00:30:10 -0000
              @@ -7142,6 +7142,13 @@ showmode()
              if (do_mode)
              {
              MSG_PUTS_ATTR("--", attr);
              +#if defined(FEAT_XIM)
              + {
              + extern int xim_preediting;
              + if (xim_preediting)
              + MSG_PUTS_ATTR(" XIM", attr);
              + }
              +#endif
              #if defined(FEAT_HANGULIN) && defined(FEAT_GUI)
              if (gui.in_use)
              {
            • Bram Moolenaar
              ... Yes, I prefer this above using the statusline, because the statusline isn t always present. Still, when editing the command line there is no mode shown.
              Message 6 of 6 , Apr 21, 2001
              • 0 Attachment
                Nam SungHyun wrote:

                > Bram Moolenaar wrote:
                > >
                > > Steven Mueller wrote:
                > >
                > > > I decided to look into setting up a vim variable v:preediting
                > > > (probably not the best of names...). Getting this working wasn't
                > > > difficult, but I can't seem to get the status line to refresh when
                > > > preedit mode is activated or deactivated.
                > >
                > > Thanks for looking into this. I'm not sure if using a v: variable for
                > > this is the best choice, but we can think about that later.
                >
                > How about like this?

                Yes, I prefer this above using the statusline, because the statusline isn't
                always present.

                Still, when editing the command line there is no mode shown. This probably
                does require doing something with the cursor (color or shape). Or is there
                another way?

                I'll include this patch for now, we can further improve it later. I'll move
                the global variable to globals.h.

                --
                Microsoft's definition of a boolean: TRUE, FALSE, MAYBE
                "Embrace and extend"...?

                /// Bram Moolenaar -- Bram@... -- http://www.moolenaar.net \\\
                ((( Creator of Vim - http://www.vim.org -- ftp://ftp.vim.org/pub/vim )))
                \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///
              Your message has been successfully submitted and would be delivered to recipients shortly.