statusline, display hand-defined IPA or other arbitrary text for character under cursor

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

statusline, display hand-defined IPA or other arbitrary text for character under cursor

krbeesley
In my 'set statusline' in .gvimrc, I have a very helpful 0x%04B code that displays the hex code point value (minimum four hex digits, zero padded) of the buffer character under the cursor.

In addition to that, I'd like to be able to display an arbitrary hand-defined character or string of characters that might represent the pronunciation (e.g. in the International Phonetic Alphabet) or a keymap input sequence.

In particular, I have defined a Japanese-hiragana keymap that allows me to type hi, which is intercepted by the keymap, which places the Japanese hiragana character 0x3072 in the (g)vim buffer.  The line in the keymap looks like this:

hi   <Char-0x3072>

That works just fine.
But in addition, I'd essentially like the status line to display the reverse, such that when the cursor is on a 0x3072 character, I'd also like the statusline to display (for my own benefit) the letters hi.   I don't expect vim to know that 0x3072 should cause "hi" to be displayed in the statusline---rather I would define that somewhere, in a kind of reverse-keymap file.

The same mechanism could be used to display IPA symbols, or whatever, when the cursor is on a Greek, Russian, Georgian, or whatever character.

Any help would be much appreciated.
Ken

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: statusline, display hand-defined IPA or other arbitrary text for character under cursor

krbeesley
On Wednesday, May 30, 2018 at 2:03:21 PM UTC-6, Kenneth Reid Beesley wrote:

> In my 'set statusline' in .gvimrc, I have a very helpful 0x%04B code that displays the hex code point value (minimum four hex digits, zero padded) of the buffer character under the cursor.
>
> In addition to that, I'd like to be able to display an arbitrary hand-defined character or string of characters that might represent the pronunciation (e.g. in the International Phonetic Alphabet) or a keymap input sequence.
>
> In particular, I have defined a Japanese-hiragana keymap that allows me to type hi, which is intercepted by the keymap, which places the Japanese hiragana character 0x3072 in the (g)vim buffer.  The line in the keymap looks like this:
>
> hi   <Char-0x3072>
>
> That works just fine.
> But in addition, I'd essentially like the status line to display the reverse, such that when the cursor is on a 0x3072 character, I'd also like the statusline to display (for my own benefit) the letters hi.   I don't expect vim to know that 0x3072 should cause "hi" to be displayed in the statusline---rather I would define that somewhere, in a kind of reverse-keymap file.
>
> The same mechanism could be used to display IPA symbols, or whatever, when the cursor is on a Greek, Russian, Georgian, or whatever character.
I'm using gvim (MacVim).

I've got at least the beginnings of a solution (corrections and suggestions would be welcome).  The attached file revkeymap.vim (which resides in ~/.vim/plugin/) defines the function Revkeymap(), which defines a dict mapping code point values to the little strings that I want to be displayed.  So, for example, the Japanese hiragana character 0x3072 is mapped to "hi", 0x3073 is mapped to "bi", etc.  The function retrieves the current character under the cursor, converts it to a number (the code point value), looks up the code point value in the dict, and returns the associated string.  If they key is not in the dict, then an empty string is returned.

The function is called in  'set statusline' as %{Revkeymap()}, so the "hi" string gets returned and displayed in the statusline when the cursor is over the 0x3072 character.  The mapping could be extended, of course, to define IPA displays for Russian, Greek, Georgian, or whatever characters.

My problem now is that I can input the hiragana characters, but the glyphs must be coming from some default font in the operating system (I'm using MacVim).  The glyphs are wider than the glyphs in the mono font specified with 'set guifont', and so the cursor doesn't align properly with the glyphs.  The buffer has a mixture of Roman character glyphs (from the mono font) and wider hiragana glyphs (from who-knows-where).

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

revkeymap.vim (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: statusline, display hand-defined IPA or other arbitrary text for character under cursor

Lifepillar
On 31/05/2018 18:46, Kenneth Reid Beesley wrote:
> On Wednesday, May 30, 2018 at 2:03:21 PM UTC-6, Kenneth Reid Beesley wrote:

> My problem now is that I can input the hiragana characters, but the glyphs must be coming from some default font in the operating system (I'm using MacVim).  The glyphs are wider than the glyphs in the mono font specified with 'set guifont', and so the cursor doesn't align properly with the glyphs.  The buffer has a mixture of Roman character glyphs (from the mono font) and wider hiragana glyphs (from who-knows-where).

Do you have a specific sequence of glyphs to help us reproduce your
issue? I have tried mixing Latin with 0x3072 and 0x3073 (e.g.,
xひyびwひzび), but what I see is that upon moving over such strings
the cursor becomes as wide (or as narrow) as the underlying character.
So, I do not understand what "the cursor doesn't align properly with the
glyphs" means. To me, it looks aligned.

Btw, have you played with "Use Core Text Renderer" in the Preferences?
Try setting/unsetting the option, then open a new document window.

You might also check ':help ambiwidth'.

Life.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: statusline, display hand-defined IPA or other arbitrary text for character under cursor

krbeesley
On Thursday, May 31, 2018 at 12:19:03 PM UTC-6, Lifepillar wrote:
> On 31/05/2018 18:46, Kenneth Reid Beesley wrote:
> > On Wednesday, May 30, 2018 at 2:03:21 PM UTC-6, Kenneth Reid Beesley wrote:
>
> > My problem now is that I can input the hiragana characters, but the glyphs must be coming from some default font in the operating system (I'm using MacVim).  The glyphs are wider than the glyphs in the mono font specified with 'set guifont', and so the cursor doesn't align properly with the glyphs.  The buffer has a mixture of Roman character glyphs (from the mono font) and wider hiragana glyphs (from who-knows-where).
>
>... <snip>...</snip>
>
> Btw, have you played with "Use Core Text Renderer" in the Preferences?
> Try setting/unsetting the option, then open a new document window.

Thank you Life.   Selecting "Use Core Text Renderer" seems to solve the problem!

Ken

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.