change to C++ version, add initial python script
This commit is contained in:
parent
26b713807a
commit
545ce108f1
1
Makefile
1
Makefile
@ -8,3 +8,4 @@ all: $(TARGET)
|
||||
|
||||
install: $(TARGET)
|
||||
cp $(TARGET) $(INSTALL_DIR)
|
||||
cp $(TARGET).py $(INSTALL_DIR)
|
||||
|
@ -1,20 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char **new_argv = malloc(sizeof(char *) * (argc + 2));
|
||||
int i = 0;
|
||||
new_argv[i++] = "gvim";
|
||||
new_argv[i++] = "--remote-tab-silent";
|
||||
for (int n = 1; n < argc; n++, i++)
|
||||
{
|
||||
new_argv[i] = malloc(strlen(argv[n]) + 3);
|
||||
sprintf(new_argv[i], "\"%s\"", argv[n]);
|
||||
}
|
||||
new_argv[i++] = NULL;
|
||||
execv("C:\\apps\\Vim\\vim73\\gvim.exe", (const char * const *) new_argv);
|
||||
return -1;
|
||||
}
|
22
gvim-wrapper.cc
Normal file
22
gvim-wrapper.cc
Normal file
@ -0,0 +1,22 @@
|
||||
#include <unistd.h>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
string program_name = argv[0];
|
||||
size_t pos = program_name.find_last_of("/\\");
|
||||
string script_path =
|
||||
(pos != string::npos)
|
||||
? program_name.substr(0, pos) + "/gvim-wrapper.py"
|
||||
: "gvim-wrapper.py";
|
||||
const char **new_argv = new const char *[argc + 2];
|
||||
memcpy(&new_argv[2], &argv[1], argc * sizeof(new_argv[0]));
|
||||
new_argv[0] = "pythonw.exe";
|
||||
new_argv[1] = script_path.c_str();
|
||||
new_argv[argc + 1] = NULL;
|
||||
argv[0] = "gvim-wrapper.py";
|
||||
execvp("pythonw.exe", new_argv);
|
||||
return -1;
|
||||
}
|
10
gvim-wrapper.py
Normal file
10
gvim-wrapper.py
Normal file
@ -0,0 +1,10 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
def main(argv):
|
||||
fh = open('C:\\out.txt', 'w')
|
||||
fh.write('called with args: "%s"\n' % ', '.join(argv))
|
||||
fh.close()
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv))
|
Loading…
x
Reference in New Issue
Block a user