Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented main xkbswitch logic in separate file. #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

iarkhanhelsky
Copy link

Now possible ship xkbswitch with .dylib.

  • Added following functions for setting and getting layouts
    • int Xkb_Switch_setXkbLayoutAsNum(int id);
    • int Xkb_Switch_setXkbLayoutAsString( const char* name );
    • int Xkb_Switch_getXkbLayoutAsNum();
    • char * Xkb_Switch_getXkbLayoutAsString();
  • Added following functions for setting and getting layouts to keep
    backward compatibility with vim-xkbswitch
    • const char* Xkb_Switch_setXkbLayout( const char * param );
    • char * Xkb_Switch_getXkbLayout( const char * param );
  • Added xcode project target for building libxkbswitch.dylib

Now possible ship xkbswitch with `.dylib`.

- Added following functions for setting and getting layouts
  - `int Xkb_Switch_setXkbLayoutAsNum(int id);`
  - `int Xkb_Switch_setXkbLayoutAsString( const char* name );`
  - `int Xkb_Switch_getXkbLayoutAsNum();`
  - `char * Xkb_Switch_getXkbLayoutAsString();`
- Added following functions for setting and getting layouts to keep
  backward compatibility with `vim-xkbswitch`
  - `const char* Xkb_Switch_setXkbLayout( const char * param );`
  - `char * Xkb_Switch_getXkbLayout( const char * param );`
- Added xcode project target for building `libxkbswitch.dylib`
@iarkhanhelsky
Copy link
Author

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
Copy link
Owner

myshov commented Mar 25, 2018

@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
Copy link
Owner

myshov commented Mar 25, 2018

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
Copy link
Author

At first glance it works fine in mvim.

@myshov
Copy link
Owner

myshov commented Nov 4, 2018

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
Copy link
Author

@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
Copy link
Owner

myshov commented Nov 7, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants