myshov / xkbswitch-macosx

Console keyboard layout switcher for MacOS
218 stars 26 forks source link

Implemented main xkbswitch logic in separate file. #6

Open iarkhanhelsky opened 6 years ago

iarkhanhelsky commented 6 years ago

Now possible ship xkbswitch with .dylib.

iarkhanhelsky commented 6 years ago

Need to use current library with hardcoded paths to /usr/local/bin makes me really sad.

Note that I'm using malloc again. Possible memory leak. But I can't find how vim frees this string pointers.

myshov commented 6 years ago

@iarkhanhelsky thank you for contribution! I don't have a lot of time now to check your pull request thoroughly. But I will do it anyway, so please give me a pardon for the inactivity in the near future :)

myshov commented 6 years ago

By the way, can you please check your solution in MacVim? The last time when I tried implement dylib for vim I had encountered with strange MacVim behaviour. I don't remember what exactly was happened, but it was connected with a process instantiation somehow.

iarkhanhelsky commented 6 years ago

At first glance it works fine in mvim.

myshov commented 5 years ago

Hi Ilya! I managed to find some time to test your pr, but there is a problem - libxkbswitch.dylib keeps return me zero again and again because of that vim-xkbswitch plugin doesn't work properly. I have tested call to library with this command:

:echo libcall(g:XkbSwitchLib, 'Xkb_Switch_getXkbLayout', '')

Did you experience something like that? My macOS 10.12, XCode 9.2, Vim 8

iarkhanhelsky commented 5 years ago

@myshov I did some checks on my machine (Mac OS 10.13., Vim 8, XCode 9). I have tested following commands:

:echo libcall(g:XkbSwitchLib, 'Xkb_Switch_getXkbLayout', '')   => 0 every time 
:echo libcall(g:XkbSwitchLib, 'Xkb_Switch_getXkbLayoutAsString', '') => US every time

Then I tested xkbswitch executable. And it works fine, though it uses same code. So I have no idea what had changed if anything changed at all...

Unfortunately I'm not using Mac OS anymore on regular basis and can't be very useful on fixing it. Feel free to reject this pull request if your master branch works well and you have no time to investigate this right now.

myshov commented 5 years ago

Thank you for quick response! Anyway I'll try to find the reason of this behaviour in the future. I'll leave your pr opened.