diff options
author | 2009-01-19 23:25:01 -0500 | |
---|---|---|
committer | 2009-01-19 23:25:01 -0500 | |
commit | 791fc92dc7bf15efff444004128b90b8b53ca14f (patch) | |
tree | f1dcc6dd70f5f69409cb0ba6aef2f4eb78734589 | |
parent | 73da184d79d6219101f57a01519c04c0057a15c1 (diff) | |
download | textadept-791fc92dc7bf15efff444004128b90b8b53ca14f.tar.gz textadept-791fc92dc7bf15efff444004128b90b8b53ca14f.zip |
Command line parameters can now be used in Windows.
-rw-r--r-- | init.lua | 11 | ||||
-rw-r--r-- | src/textadept.c | 2 |
2 files changed, 12 insertions, 1 deletions
@@ -33,6 +33,17 @@ require 'ext/menu' -- provides the menu bar require 'ext/key_commands' -- key commands for Mitchell (Nano-Emacs hybrid) if not RESETTING then + -- for Windows, create arg table from single command line string (arg[0]) + if WIN32 and #arg[0] > 0 then + local lpeg = require 'lpeg' + local P, S, C, Ct = lpeg.P, lpeg.S, lpeg.C, lpeg.Ct + space = P(' ') + param = P('"') * C((1 - P('"'))^0) * '"' + C((1 - space)^1) + cmdline = Ct(param * (space * param)^0) + args = lpeg.match(cmdline, arg[0]) + for _, a in ipairs(args) do arg[#arg + 1] = a end + end + -- process command line arguments if MAC and arg[1] and arg[1]:match('^%-psn_0') then table.remove(arg, 1) diff --git a/src/textadept.c b/src/textadept.c index 81408d32..a76717e8 100644 --- a/src/textadept.c +++ b/src/textadept.c @@ -115,7 +115,7 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR lpCmdLine, int) { char *last_slash = strrchr(path, '\\'); if (last_slash) *last_slash = '\0'; textadept_home = static_cast<char*>(path); - return main(0, NULL); + return main(1, &lpCmdLine); } #endif |