lua api improvements
This commit is contained in:
@@ -184,6 +184,8 @@ char *C(const char *value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
S8_String LuaScript = R"==(
|
S8_String LuaScript = R"==(
|
||||||
|
INTERNET_BROWSER = 'C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe'
|
||||||
|
|
||||||
SDLK_CTRL = 1073742048
|
SDLK_CTRL = 1073742048
|
||||||
SDLK_PAGE_DOWN = 1073741902
|
SDLK_PAGE_DOWN = 1073741902
|
||||||
SDLK_PAGE_UP = 1073741899
|
SDLK_PAGE_UP = 1073741899
|
||||||
@@ -336,32 +338,19 @@ function SkipPath(s)
|
|||||||
return s, path, drive, cells
|
return s, path, drive, cells
|
||||||
end
|
end
|
||||||
|
|
||||||
function BufferNameExists(name)
|
|
||||||
buffers = GetBufferList()
|
|
||||||
for i = 1,#buffers do
|
|
||||||
buff = buffers[i]
|
|
||||||
if buff == name then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
function MatchWindowsPath(_s)
|
function MatchWindowsPath(_s)
|
||||||
local s, file_path, drive = SkipPath(_s)
|
local s, file_path, drive = SkipPath(_s)
|
||||||
if not file_path then return nil end
|
if not file_path then return nil end
|
||||||
|
|
||||||
if not drive then
|
if not drive then
|
||||||
local d = GetActiveMainWindowBufferDir()
|
local d = GetDir()
|
||||||
file_path = d..'/'..file_path
|
file_path = d..'/'..file_path
|
||||||
end
|
end
|
||||||
local line, col, s = SkipLineAndColumn(s)
|
local line, col, s = SkipLineAndColumn(s)
|
||||||
|
|
||||||
local exists = FileExists(file_path) or BufferNameExists(file_path)
|
local exists = FileExists(file_path) or BufferExists(file_path)
|
||||||
if not exists then return nil end
|
if not exists then return nil end
|
||||||
|
|
||||||
|
|
||||||
Print("OPEN :: INPUT = ".._s.." KIND = ".."text".." ".."FILE_PATH = "..file_path.."["..line..","..col.."]")
|
|
||||||
return {kind = "text", file_path = file_path, line = line, col = col}
|
return {kind = "text", file_path = file_path, line = line, col = col}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -370,16 +359,15 @@ function MatchGitCommit(s)
|
|||||||
if i then
|
if i then
|
||||||
s = s:sub(8)
|
s = s:sub(8)
|
||||||
local command = "git --no-pager show "..s
|
local command = "git --no-pager show "..s
|
||||||
return {kind = "exec", cmd = command, working_dir = GetActiveMainWindowBufferDir()}
|
return {kind = "exec", cmd = command, working_dir = GetDir()}
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
InternetBrowser = 'C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe'
|
|
||||||
function MatchURL(s)
|
function MatchURL(s)
|
||||||
local i, j = string.find(s, "^https://")
|
local i, j = string.find(s, "^https://")
|
||||||
if i then
|
if i then
|
||||||
return {kind = "exec_console", cmd = '"'..InternetBrowser..'" '..s, working_dir = GetActiveMainWindowBufferDir()}
|
return {kind = "exec_console", cmd = '"'..INTERNET_BROWSER..'" '..s, working_dir = GetDir()}
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
@@ -429,8 +417,6 @@ table.insert(OnCommandCallbacks, function (e)
|
|||||||
Eval(GetLoadWord()) end
|
Eval(GetLoadWord()) end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- REMEBER: AS LITTLE ACTUAL CODE AS POSSIBLE IN LUA
|
|
||||||
-- ONLY CONFIGURABLES
|
|
||||||
function OnCommand(e)
|
function OnCommand(e)
|
||||||
for i = #OnCommandCallbacks,1,-1 do
|
for i = #OnCommandCallbacks,1,-1 do
|
||||||
on_command = OnCommandCallbacks[i]
|
on_command = OnCommandCallbacks[i]
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ void MouseLoadWord(Event event, bool cut_path) {
|
|||||||
|
|
||||||
active.view->carets.len = 1;
|
active.view->carets.len = 1;
|
||||||
active.view->carets[0] = MakeCaret(p);
|
active.view->carets[0] = MakeCaret(p);
|
||||||
Open(string);
|
Command_Open(string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -817,7 +817,7 @@ void Command_GotoNextInList(Window *window, Int line_offset = 1) {
|
|||||||
if (line.len == 0) continue;
|
if (line.len == 0) continue;
|
||||||
|
|
||||||
CheckpointBeforeGoto(window, active_view);
|
CheckpointBeforeGoto(window, active_view);
|
||||||
Open(line);
|
Command_Open(line);
|
||||||
opened = true;
|
opened = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -483,7 +483,7 @@ void OnCommand(Event event) {
|
|||||||
if (StartsWith(right_part, "/+")) {
|
if (StartsWith(right_part, "/+")) {
|
||||||
CutLastSlash(&string);
|
CutLastSlash(&string);
|
||||||
}
|
}
|
||||||
Open(string);
|
Command_Open(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CtrlPress(SDLK_T)) {
|
if (CtrlPress(SDLK_T)) {
|
||||||
@@ -506,14 +506,14 @@ void OnCommand(Event event) {
|
|||||||
CutLastSlash(&string);
|
CutLastSlash(&string);
|
||||||
}
|
}
|
||||||
|
|
||||||
Open(string);
|
Command_Open(string);
|
||||||
} else if (CtrlPress(SDLK_Q)) {
|
} else if (CtrlPress(SDLK_Q)) {
|
||||||
Caret caret = active.view->carets[0];
|
Caret caret = active.view->carets[0];
|
||||||
Range range = caret.range;
|
Range range = caret.range;
|
||||||
if (GetSize(caret.range) == 0) range = EncloseLoadWord(active.buffer, GetFront(caret));
|
if (GetSize(caret.range) == 0) range = EncloseLoadWord(active.buffer, GetFront(caret));
|
||||||
String16 string = GetString(active.buffer, range);
|
String16 string = GetString(active.buffer, range);
|
||||||
|
|
||||||
Open(string);
|
Command_Open(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Press(SDLK_ESCAPE)) {
|
if (Press(SDLK_ESCAPE)) {
|
||||||
|
|||||||
@@ -68,6 +68,8 @@ Style.FontFilter = 0
|
|||||||
Style.Font = "C:/Windows/Fonts/consola.ttf"
|
Style.Font = "C:/Windows/Fonts/consola.ttf"
|
||||||
Style.VCVarsall = "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build/vcvars64.bat"
|
Style.VCVarsall = "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build/vcvars64.bat"
|
||||||
|
|
||||||
|
INTERNET_BROWSER = 'C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe'
|
||||||
|
|
||||||
SDLK_CTRL = 1073742048
|
SDLK_CTRL = 1073742048
|
||||||
SDLK_PAGE_DOWN = 1073741902
|
SDLK_PAGE_DOWN = 1073741902
|
||||||
SDLK_PAGE_UP = 1073741899
|
SDLK_PAGE_UP = 1073741899
|
||||||
@@ -220,32 +222,19 @@ function SkipPath(s)
|
|||||||
return s, path, drive, cells
|
return s, path, drive, cells
|
||||||
end
|
end
|
||||||
|
|
||||||
function BufferNameExists(name)
|
|
||||||
buffers = GetBufferList()
|
|
||||||
for i = 1,#buffers do
|
|
||||||
buff = buffers[i]
|
|
||||||
if buff == name then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
function MatchWindowsPath(_s)
|
function MatchWindowsPath(_s)
|
||||||
local s, file_path, drive = SkipPath(_s)
|
local s, file_path, drive = SkipPath(_s)
|
||||||
if not file_path then return nil end
|
if not file_path then return nil end
|
||||||
|
|
||||||
if not drive then
|
if not drive then
|
||||||
local d = GetActiveMainWindowBufferDir()
|
local d = GetDir()
|
||||||
file_path = d..'/'..file_path
|
file_path = d..'/'..file_path
|
||||||
end
|
end
|
||||||
local line, col, s = SkipLineAndColumn(s)
|
local line, col, s = SkipLineAndColumn(s)
|
||||||
|
|
||||||
local exists = FileExists(file_path) or BufferNameExists(file_path)
|
local exists = FileExists(file_path) or BufferExists(file_path)
|
||||||
if not exists then return nil end
|
if not exists then return nil end
|
||||||
|
|
||||||
|
|
||||||
Print("OPEN :: INPUT = ".._s.." KIND = ".."text".." ".."FILE_PATH = "..file_path.."["..line..","..col.."]")
|
|
||||||
return {kind = "text", file_path = file_path, line = line, col = col}
|
return {kind = "text", file_path = file_path, line = line, col = col}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -254,16 +243,15 @@ function MatchGitCommit(s)
|
|||||||
if i then
|
if i then
|
||||||
s = s:sub(8)
|
s = s:sub(8)
|
||||||
local command = "git --no-pager show "..s
|
local command = "git --no-pager show "..s
|
||||||
return {kind = "exec", cmd = command, working_dir = GetActiveMainWindowBufferDir()}
|
return {kind = "exec", cmd = command, working_dir = GetDir()}
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
InternetBrowser = 'C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe'
|
|
||||||
function MatchURL(s)
|
function MatchURL(s)
|
||||||
local i, j = string.find(s, "^https://")
|
local i, j = string.find(s, "^https://")
|
||||||
if i then
|
if i then
|
||||||
return {kind = "exec_console", cmd = '"'..InternetBrowser..'" '..s, working_dir = GetActiveMainWindowBufferDir()}
|
return {kind = "exec_console", cmd = '"'..INTERNET_BROWSER..'" '..s, working_dir = GetDir()}
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
@@ -313,8 +301,6 @@ table.insert(OnCommandCallbacks, function (e)
|
|||||||
Eval(GetLoadWord()) end
|
Eval(GetLoadWord()) end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- REMEBER: AS LITTLE ACTUAL CODE AS POSSIBLE IN LUA
|
|
||||||
-- ONLY CONFIGURABLES
|
|
||||||
function OnCommand(e)
|
function OnCommand(e)
|
||||||
for i = #OnCommandCallbacks,1,-1 do
|
for i = #OnCommandCallbacks,1,-1 do
|
||||||
on_command = OnCommandCallbacks[i]
|
on_command = OnCommandCallbacks[i]
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ View *Command_ExecHidden(String buffer_name, String cmd, String working_dir) {
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Open(String path) {
|
void Command_Open(String path) {
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
|
|
||||||
lua_getglobal(LuaState, "ApplyRules");
|
lua_getglobal(LuaState, "ApplyRules");
|
||||||
@@ -81,16 +81,16 @@ void Open(String path) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Open(String16 path) {
|
void Command_Open(String16 path) {
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
String string = ToString(scratch, path);
|
String string = ToString(scratch, path);
|
||||||
Open(string);
|
Command_Open(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Lua_AppendCmd(lua_State *L) {
|
int Lua_AppendCmd(lua_State *L) {
|
||||||
String string = lua_tostring(L, 1);
|
String string = lua_tostring(L, 1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
String working_dir = GetActiveMainWindowBufferDir();
|
String working_dir = Command_GetDir();
|
||||||
Exec(NullViewID, true, string, working_dir);
|
Exec(NullViewID, true, string, working_dir);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ int Lua_C(lua_State *L) {
|
|||||||
String string = lua_tostring(L, 1);
|
String string = lua_tostring(L, 1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
|
||||||
String working_dir = GetActiveMainWindowBufferDir();
|
String working_dir = Command_GetDir();
|
||||||
BSet set = GetActiveMainSet();
|
BSet set = GetActiveMainSet();
|
||||||
Command_ExecInNewBuffer(set, string, working_dir);
|
Command_ExecInNewBuffer(set, string, working_dir);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -152,6 +152,18 @@ int Lua_Cmd(lua_State *L) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Lua_Print(lua_State *L) {
|
||||||
|
Scratch scratch;
|
||||||
|
int nargs = lua_gettop(L);
|
||||||
|
View *null_view = GetView(NullViewID);
|
||||||
|
for (int i = 1; i <= nargs; i += 1) {
|
||||||
|
String string = lua_tostring(L, i);
|
||||||
|
Command_Append(null_view, string, true);
|
||||||
|
}
|
||||||
|
lua_pop(L, nargs);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int Lua_Kill(lua_State *L) {
|
int Lua_Kill(lua_State *L) {
|
||||||
BSet main = GetActiveMainSet();
|
BSet main = GetActiveMainSet();
|
||||||
KillProcess(main.view);
|
KillProcess(main.view);
|
||||||
@@ -188,7 +200,7 @@ int Lua_Open(lua_State *L) {
|
|||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
String path = luaL_checkstring(L, 1);
|
String path = luaL_checkstring(L, 1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
Open(path);
|
Command_Open(path);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,16 +223,6 @@ int Lua_ToggleFullscreen(lua_State *L) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Lua_Print(lua_State *L) {
|
|
||||||
Scratch scratch;
|
|
||||||
String string = lua_tostring(L, 1);
|
|
||||||
lua_pop(L, 1);
|
|
||||||
|
|
||||||
View *null_view = GetView(NullViewID);
|
|
||||||
Command_Append(null_view, string, true);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Lua_ListBuffers(lua_State *L) {
|
int Lua_ListBuffers(lua_State *L) {
|
||||||
Command_ListBuffers();
|
Command_ListBuffers();
|
||||||
return 0;
|
return 0;
|
||||||
@@ -240,28 +242,11 @@ int Lua_GetBufferList(lua_State *L) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Lua_FileExists(lua_State *L) {
|
int Lua_BufferExists(lua_State *L) {
|
||||||
String path = luaL_checkstring(L, 1);
|
String string = lua_tostring(L, 1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
bool exists = FileExists(path);
|
Buffer *buffer = BufferNameExists(string);
|
||||||
lua_pushboolean(L, exists);
|
lua_pushboolean(L, buffer != NULL);
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Lua_GetWorkingDir(lua_State *L) {
|
|
||||||
lua_pushlstring(L, WorkingDir.data, WorkingDir.len);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Lua_GetActiveMainWindowBufferName(lua_State *L) {
|
|
||||||
String name = GetActiveMainWindowBufferName();
|
|
||||||
lua_pushlstring(L, name.data, name.len);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Lua_GetActiveMainWindowBufferDir(lua_State *L) {
|
|
||||||
String name = GetActiveMainWindowBufferDir();
|
|
||||||
lua_pushlstring(L, name.data, name.len);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,7 +269,7 @@ int Lua_Ls(lua_State *L) {
|
|||||||
String buffer_name = GetUniqueBufferName(scratch, GetDir(main.buffer), "+ls-");
|
String buffer_name = GetUniqueBufferName(scratch, GetDir(main.buffer), "+ls-");
|
||||||
|
|
||||||
Buffer *buffer = CreateBuffer(GetSystemAllocator(), buffer_name, 4096 * 4);
|
Buffer *buffer = CreateBuffer(GetSystemAllocator(), buffer_name, 4096 * 4);
|
||||||
ListFilesRecursive(buffer, GetActiveMainWindowBufferDir());
|
ListFilesRecursive(buffer, Command_GetDir());
|
||||||
WindowOpenBufferView(main.window, buffer_name);
|
WindowOpenBufferView(main.window, buffer_name);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -338,6 +323,25 @@ int Lua_GetProjectPath(lua_State *L) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Lua_FileExists(lua_State *L) {
|
||||||
|
String path = luaL_checkstring(L, 1);
|
||||||
|
lua_pop(L, 1);
|
||||||
|
bool exists = FileExists(path);
|
||||||
|
lua_pushboolean(L, exists);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Lua_GetWorkingDir(lua_State *L) {
|
||||||
|
lua_pushlstring(L, WorkingDir.data, WorkingDir.len);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Lua_GetDir(lua_State *L) {
|
||||||
|
String name = Command_GetDir();
|
||||||
|
lua_pushlstring(L, name.data, name.len);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static void HookLuaForceExit(lua_State *L, lua_Debug *debug) {
|
static void HookLuaForceExit(lua_State *L, lua_Debug *debug) {
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
int numkeys = 0;
|
int numkeys = 0;
|
||||||
@@ -500,20 +504,6 @@ void ReloadLuaConfigs() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CallIsLoadWord(char16_t c) {
|
|
||||||
lua_getglobal(LuaState, "IsLoadWord");
|
|
||||||
lua_pushinteger(LuaState, c);
|
|
||||||
if (lua_pcall(LuaState, 1, 1, 0) != 0) {
|
|
||||||
const char *error_message = lua_tostring(LuaState, -1);
|
|
||||||
ReportWarningf("Failed the call to IsLoadWord! %s", error_message);
|
|
||||||
lua_pop(LuaState, 1);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
bool result = lua_toboolean(LuaState, -1);
|
|
||||||
lua_pop(LuaState, 1);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CallOnCommand(Event *event) {
|
void CallOnCommand(Event *event) {
|
||||||
lua_getglobal(LuaState, "OnCommand");
|
lua_getglobal(LuaState, "OnCommand");
|
||||||
PushEvent(LuaState, event);
|
PushEvent(LuaState, event);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ luaL_Reg LuaFunctions[] = {
|
|||||||
{"Eval", Lua_Eval},
|
{"Eval", Lua_Eval},
|
||||||
{"C", Lua_C},
|
{"C", Lua_C},
|
||||||
{"Cmd", Lua_Cmd},
|
{"Cmd", Lua_Cmd},
|
||||||
|
{"Print", Lua_Print},
|
||||||
{"Kill", Lua_Kill},
|
{"Kill", Lua_Kill},
|
||||||
{"GetLoadWord", Lua_GetLoadWord},
|
{"GetLoadWord", Lua_GetLoadWord},
|
||||||
{"New", Lua_New},
|
{"New", Lua_New},
|
||||||
@@ -10,13 +11,9 @@ luaL_Reg LuaFunctions[] = {
|
|||||||
{"SetProjectFile", Lua_SetProjectFile},
|
{"SetProjectFile", Lua_SetProjectFile},
|
||||||
{"Reopen", Lua_Reopen},
|
{"Reopen", Lua_Reopen},
|
||||||
{"ToggleFullscreen", Lua_ToggleFullscreen},
|
{"ToggleFullscreen", Lua_ToggleFullscreen},
|
||||||
{"Print", Lua_Print},
|
|
||||||
{"ListBuffers", Lua_ListBuffers},
|
{"ListBuffers", Lua_ListBuffers},
|
||||||
{"GetBufferList", Lua_GetBufferList},
|
{"GetBufferList", Lua_GetBufferList},
|
||||||
{"FileExists", Lua_FileExists},
|
{"BufferExists", Lua_BufferExists},
|
||||||
{"GetWorkingDir", Lua_GetWorkingDir},
|
|
||||||
{"GetActiveMainWindowBufferName", Lua_GetActiveMainWindowBufferName},
|
|
||||||
{"GetActiveMainWindowBufferDir", Lua_GetActiveMainWindowBufferDir},
|
|
||||||
{"Ls", Lua_Ls},
|
{"Ls", Lua_Ls},
|
||||||
{"Rename", Lua_Rename},
|
{"Rename", Lua_Rename},
|
||||||
{"GetSelection", Lua_GetSelection},
|
{"GetSelection", Lua_GetSelection},
|
||||||
@@ -24,6 +21,9 @@ luaL_Reg LuaFunctions[] = {
|
|||||||
{"GetClipboard", Lua_GetClipboard},
|
{"GetClipboard", Lua_GetClipboard},
|
||||||
{"GetFilename", Lua_GetFilename},
|
{"GetFilename", Lua_GetFilename},
|
||||||
{"GetProjectPath", Lua_GetProjectPath},
|
{"GetProjectPath", Lua_GetProjectPath},
|
||||||
|
{"FileExists", Lua_FileExists},
|
||||||
|
{"GetWorkingDir", Lua_GetWorkingDir},
|
||||||
|
{"GetDir", Lua_GetDir},
|
||||||
{"Play", Lua_Play},
|
{"Play", Lua_Play},
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ String GetUniqueBufferName(Allocator allocator, String working_dir, String p
|
|||||||
return buffer_name;
|
return buffer_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
String GetActiveMainWindowBufferName() {
|
String Command_GetFilename() {
|
||||||
BSet set = GetActiveMainSet();
|
BSet set = GetActiveMainSet();
|
||||||
return set.buffer->name;
|
return set.buffer->name;
|
||||||
}
|
}
|
||||||
@@ -248,7 +248,7 @@ String GetDir(Buffer *buffer) {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
String GetActiveMainWindowBufferDir() {
|
String Command_GetDir() {
|
||||||
BSet set = GetActiveMainSet();
|
BSet set = GetActiveMainSet();
|
||||||
String name = ChopLastSlash(set.buffer->name);
|
String name = ChopLastSlash(set.buffer->name);
|
||||||
return name;
|
return name;
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ Array<Event> GetEventsForFrame(Allocator allocator) {
|
|||||||
|
|
||||||
void Windows_SetupVCVarsall(mco_coro *co) {
|
void Windows_SetupVCVarsall(mco_coro *co) {
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
String working_dir = GetActiveMainWindowBufferDir();
|
String working_dir = Command_GetDir();
|
||||||
String buffer_name = GetUniqueBufferName(scratch, working_dir, "+cmd-");
|
String buffer_name = GetUniqueBufferName(scratch, working_dir, "+cmd-");
|
||||||
String cmd = Format(scratch, "\"%.*s\" && set", FmtString(StyleVCVarsall));
|
String cmd = Format(scratch, "\"%.*s\" && set", FmtString(StyleVCVarsall));
|
||||||
View *view = Command_ExecHidden(buffer_name, cmd, working_dir);
|
View *view = Command_ExecHidden(buffer_name, cmd, working_dir);
|
||||||
|
|||||||
@@ -84,8 +84,8 @@ bool Command_EvalLua(View *view, String16 string);
|
|||||||
Rect2I GetVisibleCells(Window *window);
|
Rect2I GetVisibleCells(Window *window);
|
||||||
void AfterEdit(View *view, Array<Edit> edits);
|
void AfterEdit(View *view, Array<Edit> edits);
|
||||||
Scroller ComputeScrollerRect(Window *window);
|
Scroller ComputeScrollerRect(Window *window);
|
||||||
void Open(String path);
|
void Command_Open(String path);
|
||||||
void Open(String16 path);
|
void Command_Open(String16 path);
|
||||||
void UpdateScroll(Window *window, bool update_caret_scrolling);
|
void UpdateScroll(Window *window, bool update_caret_scrolling);
|
||||||
|
|
||||||
void Command_SelectEntireBuffer(View *view);
|
void Command_SelectEntireBuffer(View *view);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ function MatchProject(s)
|
|||||||
|
|
||||||
local line, col, s = SkipLineAndColumn(s)
|
local line, col, s = SkipLineAndColumn(s)
|
||||||
|
|
||||||
local fp = GetActiveMainWindowBufferDir().."/"..file_path
|
local fp = GetDir().."/"..file_path
|
||||||
if FileExists(fp) then
|
if FileExists(fp) then
|
||||||
return {kind = "text", file_path = fp, line = line, col = col}
|
return {kind = "text", file_path = fp, line = line, col = col}
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user