Compare commits
No commits in common. "master" and "v0.2" have entirely different histories.
5
Makefile
5
Makefile
@ -1,9 +1,8 @@
|
|||||||
|
|
||||||
TARGET := gvim-wrapper
|
TARGET := gvim-wrapper
|
||||||
CFLAGS := -std=gnu99 -mwindows
|
CFLAGS := -mno-cygwin -std=gnu99 -mwindows
|
||||||
LDFLAGS := -mwindows -static-libgcc -static-libstdc++
|
LDFLAGS := -mno-cygwin -mwindows
|
||||||
INSTALL_DIR ?= /c/apps/bin
|
INSTALL_DIR ?= /c/apps/bin
|
||||||
CXX := i686-pc-mingw32-g++
|
|
||||||
|
|
||||||
all: $(TARGET)
|
all: $(TARGET)
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -12,12 +11,12 @@ int main(int argc, char *argv[])
|
|||||||
(pos != string::npos)
|
(pos != string::npos)
|
||||||
? program_name.substr(0, pos) + "/gvim-wrapper.py"
|
? program_name.substr(0, pos) + "/gvim-wrapper.py"
|
||||||
: "gvim-wrapper.py";
|
: "gvim-wrapper.py";
|
||||||
char **new_argv = new char *[argc + 2];
|
const char **new_argv = new const char *[argc + 2];
|
||||||
memcpy(&new_argv[2], &argv[1], argc * sizeof(new_argv[0]));
|
memcpy(&new_argv[2], &argv[1], argc * sizeof(new_argv[0]));
|
||||||
new_argv[0] = (char *)"pythonw.exe";
|
new_argv[0] = "pythonw.exe";
|
||||||
new_argv[1] = (char *)script_path.c_str();
|
new_argv[1] = script_path.c_str();
|
||||||
new_argv[argc + 1] = NULL;
|
new_argv[argc + 1] = NULL;
|
||||||
argv[0] = (char *)"gvim-wrapper.py";
|
argv[0] = "gvim-wrapper.py";
|
||||||
execvp("pythonw.exe", new_argv);
|
execvp("pythonw.exe", new_argv);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,9 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
if os.path.exists('C:\\apps\\Vim\\vim74\\gvim.exe'):
|
|
||||||
vimdir = 'C:\\apps\\Vim\\vim74'
|
|
||||||
elif os.path.exists('C:\\apps\\Vim\\vim73\\gvim.exe'):
|
|
||||||
vimdir = 'C:\\apps\\Vim\\vim73'
|
|
||||||
else:
|
|
||||||
raise "Could not find Vim directory, update script"
|
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
# path to directory containing vim.exe and gvim.exe
|
# path to directory containing vim.exe and gvim.exe
|
||||||
'vimdir': vimdir,
|
'vimdir': 'C:\\apps\\Vim\\vim73',
|
||||||
# list of (path, name) tuples defining gvim contexts
|
# list of (path, name) tuples defining gvim contexts
|
||||||
'servers': [],
|
'servers': [],
|
||||||
# default server name to use if no server paths match
|
# default server name to use if no server paths match
|
||||||
@ -46,26 +39,23 @@ def get_server_name(config, fname):
|
|||||||
path = path.replace('\\', '/')
|
path = path.replace('\\', '/')
|
||||||
if path.endswith('/*'):
|
if path.endswith('/*'):
|
||||||
path = path[:-2]
|
path = path[:-2]
|
||||||
try:
|
for dirent in os.listdir(path):
|
||||||
for dirent in os.listdir(path):
|
query_path = os.path.join(path, dirent)
|
||||||
query_path = os.path.join(path, dirent)
|
if os.path.isdir(query_path) and path_contains_file(query_path, fname):
|
||||||
if os.path.isdir(query_path) and path_contains_file(query_path, fname):
|
return name.replace('*', dirent)
|
||||||
return name.replace('*', dirent)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
else:
|
else:
|
||||||
if path_contains_file(path, fname):
|
if path_contains_file(path, fname):
|
||||||
return name.replace('*', os.path.basename(path))
|
return name.replace('*', os.path.basename(path))
|
||||||
return config['default_server']
|
return config['default_server']
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
|
if (len(argv) < 2):
|
||||||
|
return -1
|
||||||
read_config_file(config, os.path.expanduser('~/.gvim-wrapper'))
|
read_config_file(config, os.path.expanduser('~/.gvim-wrapper'))
|
||||||
fname = ' '.join(argv[1:]) if len(argv) >= 2 else ''
|
for fname in argv[1:]:
|
||||||
servername = get_server_name(config, fname if fname != '' else os.getcwd() + '/dum')
|
servername = get_server_name(config, fname)
|
||||||
cmd = ['gvim', '--servername', '"%s"' % servername]
|
os.execv(config['vimdir'] + '\\gvim.exe',
|
||||||
if fname != '':
|
['gvim', '--servername', servername, '--remote-tab-silent', fname])
|
||||||
cmd += ['--remote-tab-silent', '"%s"' % fname]
|
|
||||||
os.execv(config['vimdir'] + '\\gvim.exe', cmd)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.exit(main(sys.argv))
|
sys.exit(main(sys.argv))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user