FKey function, fix goto build, GetLine, remedybg
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
CmdParser MakeCmdParser(MA_Arena *arena, int argc, char **argv, const char *custom_help) {
|
||||
CmdParser result = {argc, argv, arena, custom_help};
|
||||
return result;
|
||||
|
||||
@@ -1214,11 +1214,27 @@ void Command_ListBuffers() {
|
||||
Command_Appendf(main.view, "%.*s\n", FmtString(it->name));
|
||||
}
|
||||
}
|
||||
|
||||
int Lua_ListBuffers(lua_State *L) {
|
||||
Command_ListBuffers();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Command_ListViews() {
|
||||
BSet main = GetActiveMainSet();
|
||||
ActiveWindow = main.window->id;
|
||||
JumpGarbageBuffer(&main);
|
||||
for (View *it = FirstView; it; it = it->next) {
|
||||
Buffer *buffer = GetBuffer(it->active_buffer);
|
||||
Command_Appendf(main.view, "%d %.*s\n", (int)it->id.id, FmtString(buffer->name));
|
||||
}
|
||||
}
|
||||
|
||||
int Lua_ListViews(lua_State *L) {
|
||||
Command_ListViews();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Command_Eval(String string) {
|
||||
if (luaL_dostring(LuaState, string.data) != LUA_OK) {
|
||||
const char *error_message = lua_tostring(LuaState, -1);
|
||||
@@ -1226,10 +1242,12 @@ void Command_Eval(String string) {
|
||||
lua_pop(LuaState, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void Command_Eval(String16 string) {
|
||||
Scratch scratch;
|
||||
Command_Eval(ToString(scratch, string));
|
||||
}
|
||||
|
||||
int Lua_Eval(lua_State *L) {
|
||||
String string = lua_tostring(L, 1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
@@ -284,10 +284,10 @@ void OnCommand(Event event) {
|
||||
}
|
||||
|
||||
|
||||
if (CtrlPress(SDLK_P)) {
|
||||
Command_ListCode();
|
||||
} else if (CtrlAltPress(SDLK_P)) {
|
||||
if (CtrlAltPress(SDLK_P)) {
|
||||
Command_ListBuffers();
|
||||
} else if (CtrlPress(SDLK_P)) {
|
||||
Command_ListCode();
|
||||
}
|
||||
|
||||
if (CtrlShiftPress(SDLK_BACKSLASH)) {
|
||||
@@ -528,9 +528,9 @@ void OnCommand(Event event) {
|
||||
}
|
||||
|
||||
if (CtrlPress(SDLK_E)) {
|
||||
Command_GotoNextInList(active.window, -1);
|
||||
} else if (AltPress(SDLK_E)) {
|
||||
Command_GotoNextInList(active.window, 1);
|
||||
} else if (AltPress(SDLK_E)) {
|
||||
Command_GotoNextInList(active.window, -1);
|
||||
}
|
||||
|
||||
if (CtrlPress(SDLK_F)) {
|
||||
|
||||
@@ -379,7 +379,10 @@ function KeybindsFKeys(e)
|
||||
for i = #FKey,1,-1 do
|
||||
if FKey[i] ~= "" then
|
||||
if e.key == FKeySDLK[i] then
|
||||
Cmd { working_dir = GetWorkDir(), kind = "console", cmd = FKey[i] }
|
||||
local cmdline = FKey[i]
|
||||
if type(cmdline) == "function" then cmdline = FKey[i]() end
|
||||
Print(cmdline)
|
||||
Cmd { working_dir = GetWorkDir(), kind = "console", cmd = cmdline }
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -70,6 +70,15 @@ int Lua_GetFilename(lua_State *L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Lua_GetLine(lua_State *L) {
|
||||
BSet main = GetActiveMainSet();
|
||||
Caret caret = main.view->carets[0];
|
||||
Int front = GetFront(caret);
|
||||
Int line = PosToLine(main.buffer, front);
|
||||
lua_pushinteger(L, line + 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Lua_FileExists(lua_State *L) {
|
||||
String path = luaL_checkstring(L, 1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
@@ -7,6 +7,7 @@ luaL_Reg LuaFunctions[] = {
|
||||
{"GetEntireBuffer", Lua_GetEntireBuffer},
|
||||
{"GetClipboard", Lua_GetClipboard},
|
||||
{"GetFilename", Lua_GetFilename},
|
||||
{"GetLine", Lua_GetLine},
|
||||
{"FileExists", Lua_FileExists},
|
||||
{"GetWorkDir", Lua_GetWorkDir},
|
||||
{"GetMainDir", Lua_GetMainDir},
|
||||
@@ -26,6 +27,7 @@ luaL_Reg LuaFunctions[] = {
|
||||
{"Open", Lua_Open},
|
||||
{"Cmd", Lua_Cmd},
|
||||
{"ListBuffers", Lua_ListBuffers},
|
||||
{"ListViews", Lua_ListViews},
|
||||
{"Eval", Lua_Eval},
|
||||
{"SetProjectFile", Lua_SetProjectFile},
|
||||
{"SetWorkDir", Lua_SetWorkDir},
|
||||
|
||||
@@ -486,4 +486,4 @@ end_of_editor_loop:;
|
||||
EndProfiler();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
- Delete directory/file on disk command
|
||||
- Check. Convert more commands to taking buffer instead of view
|
||||
- Check. Rewrite more commands to use already implemented commands?
|
||||
- Lua OnCommand should be able to comunicate that we don't want C handling and do only the Lua handling
|
||||
- Lua namespaces for different kinds of commands (by ids, using main_set, using active_set)?
|
||||
- Some decl/function indexing in fuzzy format
|
||||
|
||||
- Set window layout using project file
|
||||
- Split command
|
||||
@@ -15,10 +15,6 @@
|
||||
- Open buffer using id
|
||||
- Set active window using id
|
||||
- Fix jump scroll, the query ends up the last line on screen, kind of wacky
|
||||
- Use project file as working dir instead of scratch buffer path, separate project dir and project file
|
||||
- Remedybg integration
|
||||
- GetLine()
|
||||
- in lua start debugging, jump to line, start debugger on file
|
||||
|
||||
- save all relevant buffers and build
|
||||
- maybe most of the bindings should be in lua, but actual code in C
|
||||
|
||||
Reference in New Issue
Block a user