Open iarkhanhelsky opened 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.
@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 :)
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.
At first glance it works fine in mvim.
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
@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.
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.
Now possible ship xkbswitch with
.dylib
.int Xkb_Switch_setXkbLayoutAsNum(int id);
int Xkb_Switch_setXkbLayoutAsString( const char* name );
int Xkb_Switch_getXkbLayoutAsNum();
char * Xkb_Switch_getXkbLayoutAsString();
vim-xkbswitch
const char* Xkb_Switch_setXkbLayout( const char * param );
char * Xkb_Switch_getXkbLayout( const char * param );
libxkbswitch.dylib