Giter Site home page Giter Site logo

Comments (6)

Freed-Wu avatar Freed-Wu commented on May 28, 2024

i try call libcall('/usr/local/lib/libg3kbswitch.so', 'Xkb_Switch_setXkbLayout', 'libpinyin'). the result is same as call system('g3kb-switch -s libpinyin')...

from vim-xkbswitch.

lyokha avatar lyokha commented on May 28, 2024

Hi.

I wonder, why are you calling system/lib methods when you can simply switch layout by a system method/key? Or is this for a script?

I checked behaviour with xkb-switch and I believe that g3kb-switch must behave the same way. So, why this happens:

  1. You are in Insert mode with, say, us keyboard layout,
  2. You pressed <C-o> thus effectively switching to Nomal mode, the plugin saved previous layout in Insert mode as us,
  3. You changed keyboard layout to libpinyin (I used ru) and press Enter,
  4. Insert mode returns and brings back us,

at this step you may notice a fast blink of the language selector in the system tray: it fastly switched to libpinyin and back.

Then:

  1. You exited from Insert mode and unexpectedly got libpinyin,

this is because the layout for Normal mode has been saved as well, and this was libpinyin when the Normal mode was abandoned.

To prevent this switch, you can put into the .vimrc line

let g:XkbSwitchNLayout = 'us'

Now keyboard layout in Normal mode will always be us, it seems to be a sane setting for all cases.

from vim-xkbswitch.

Freed-Wu avatar Freed-Wu commented on May 28, 2024

Now keyboard layout in Normal mode will always be us, it seems to be a sane setting for all cases.

thank for your answer! you are right.

I wonder, why are you calling system/lib methods when you can simply switch layout by a system method/key? Or is this for a script?

in truth, i want to take a try.

at this step you may notice a fast blink of the language selector in the system tray: it fastly switched to libpinyin and back.

why it fastly switch back? can i know the reason? thanks!

from vim-xkbswitch.

lyokha avatar lyokha commented on May 28, 2024

Hmm, i told you why it happens, but did not answer the question how to switch layout in Insert mode... Probably, it is not possible with the current implementation. I will tell you if I get the answer.

from vim-xkbswitch.

lyokha avatar lyokha commented on May 28, 2024

Hah, this is easily achieved if playing with the plugin internals, simply replace

<c-o>:call system('g3kb-switch -s libpinyin')<CR>

with

<c-o>:let b:xkb_ilayout='libpinyin'<CR>

Now the switch must work correctly, as you expect!

from vim-xkbswitch.

Freed-Wu avatar Freed-Wu commented on May 28, 2024

Thanks!

from vim-xkbswitch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.