RegisterCommand
This commit is contained in:
@@ -26,11 +26,6 @@ Splits:
|
|||||||
- move titlebar, search to splits?
|
- move titlebar, search to splits?
|
||||||
|
|
||||||
|
|
||||||
Linux
|
|
||||||
- Add backtrace
|
|
||||||
- Use DPI well, use as much resolution but scale with DPI
|
|
||||||
|
|
||||||
|
|
||||||
Commands TODO:
|
Commands TODO:
|
||||||
- Search
|
- Search
|
||||||
- Ctrl + F
|
- Ctrl + F
|
||||||
|
|||||||
@@ -705,7 +705,7 @@ void SaveBuffer(Buffer *buffer) {
|
|||||||
void Command_Save() {
|
void Command_Save() {
|
||||||
BSet active = GetBSet(LastActiveLayoutWindowID);
|
BSet active = GetBSet(LastActiveLayoutWindowID);
|
||||||
SaveBuffer(active.buffer);
|
SaveBuffer(active.buffer);
|
||||||
}
|
} RegisterCommand(Command_Save);
|
||||||
|
|
||||||
int Lua_Save(lua_State *L) {
|
int Lua_Save(lua_State *L) {
|
||||||
Command_Save();
|
Command_Save();
|
||||||
@@ -718,7 +718,7 @@ void Command_SaveAll() {
|
|||||||
SaveBuffer(it);
|
SaveBuffer(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} RegisterCommand(Command_SaveAll);
|
||||||
|
|
||||||
int Lua_SaveAll(lua_State *L) {
|
int Lua_SaveAll(lua_State *L) {
|
||||||
Command_SaveAll();
|
Command_SaveAll();
|
||||||
@@ -992,7 +992,7 @@ void Command_Reopen() {
|
|||||||
BSet main = GetBSet(LastActiveLayoutWindowID);
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
ReopenBuffer(main.buffer);
|
ReopenBuffer(main.buffer);
|
||||||
NextActiveWindowID = main.window->id;
|
NextActiveWindowID = main.window->id;
|
||||||
}
|
} RegisterCommand(Command_Reopen);
|
||||||
|
|
||||||
int Lua_Reopen(lua_State *L) {
|
int Lua_Reopen(lua_State *L) {
|
||||||
Command_Reopen();
|
Command_Reopen();
|
||||||
@@ -1016,15 +1016,16 @@ void New(Window *window, String name = "") {
|
|||||||
WindowOpenBufferView(window, name);
|
WindowOpenBufferView(window, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Command_New(String name = "") {
|
void Command_New() {
|
||||||
BSet main = GetBSet(LastActiveLayoutWindowID);
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
New(main.window, name);
|
New(main.window, "");
|
||||||
}
|
} RegisterCommand(Command_New);
|
||||||
|
|
||||||
int Lua_New(lua_State *L) {
|
int Lua_New(lua_State *L) {
|
||||||
String name = lua_tostring(L, 1);
|
String name = lua_tostring(L, 1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
Command_New(name);
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
|
New(main.window, name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1070,7 +1071,7 @@ void Command_ToggleFullscreen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IsInFullscreen = !IsInFullscreen;
|
IsInFullscreen = !IsInFullscreen;
|
||||||
}
|
} RegisterCommand(Command_ToggleFullscreen);
|
||||||
|
|
||||||
int Lua_ToggleFullscreen(lua_State *L) {
|
int Lua_ToggleFullscreen(lua_State *L) {
|
||||||
Command_ToggleFullscreen();
|
Command_ToggleFullscreen();
|
||||||
@@ -1102,7 +1103,7 @@ void Command_ListCode() {
|
|||||||
main.view->fuzzy_search = true;
|
main.view->fuzzy_search = true;
|
||||||
main.view->update_scroll = true;
|
main.view->update_scroll = true;
|
||||||
SelectRange(main.view, GetBufferEndAsRange(main.buffer));
|
SelectRange(main.view, GetBufferEndAsRange(main.buffer));
|
||||||
}
|
} RegisterCommand(Command_ListCode);
|
||||||
|
|
||||||
int Lua_ListCode(lua_State *L) {
|
int Lua_ListCode(lua_State *L) {
|
||||||
Command_ListCode();
|
Command_ListCode();
|
||||||
@@ -1252,7 +1253,7 @@ void Command_ShowBufferList() {
|
|||||||
}
|
}
|
||||||
command_bar.view->update_scroll = true;
|
command_bar.view->update_scroll = true;
|
||||||
SelectRange(command_bar.view, GetBufferEndAsRange(command_bar.buffer));
|
SelectRange(command_bar.view, GetBufferEndAsRange(command_bar.buffer));
|
||||||
}
|
} RegisterCommand(Command_ShowBufferList);
|
||||||
|
|
||||||
void Command_ShowCommandList() {
|
void Command_ShowCommandList() {
|
||||||
BSet command_bar = GetBSet(CommandBarWindowID);
|
BSet command_bar = GetBSet(CommandBarWindowID);
|
||||||
@@ -1265,7 +1266,7 @@ void Command_ShowCommandList() {
|
|||||||
|
|
||||||
command_bar.view->update_scroll = true;
|
command_bar.view->update_scroll = true;
|
||||||
SelectRange(command_bar.view, GetBufferEndAsRange(command_bar.buffer));
|
SelectRange(command_bar.view, GetBufferEndAsRange(command_bar.buffer));
|
||||||
}
|
} RegisterCommand(Command_ShowCommandList);
|
||||||
|
|
||||||
void Command_ListViews() {
|
void Command_ListViews() {
|
||||||
BSet command_bar = GetBSet(CommandBarWindowID);
|
BSet command_bar = GetBSet(CommandBarWindowID);
|
||||||
@@ -1279,7 +1280,7 @@ void Command_ListViews() {
|
|||||||
command_bar.view->fuzzy_search = true;
|
command_bar.view->fuzzy_search = true;
|
||||||
command_bar.view->update_scroll = true;
|
command_bar.view->update_scroll = true;
|
||||||
SelectRange(command_bar.view, GetBufferEndAsRange(command_bar.buffer));
|
SelectRange(command_bar.view, GetBufferEndAsRange(command_bar.buffer));
|
||||||
}
|
} RegisterCommand(Command_ListViews);
|
||||||
|
|
||||||
int Lua_ListViews(lua_State *L) {
|
int Lua_ListViews(lua_State *L) {
|
||||||
Command_ListViews();
|
Command_ListViews();
|
||||||
@@ -1316,7 +1317,7 @@ void SetProjectFile(Buffer *buffer) {
|
|||||||
void Command_SetProjectFile() {
|
void Command_SetProjectFile() {
|
||||||
BSet main = GetBSet(LastActiveLayoutWindowID);
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
SetProjectFile(main.buffer);
|
SetProjectFile(main.buffer);
|
||||||
}
|
} RegisterCommand(Command_SetProjectFile);
|
||||||
|
|
||||||
void Command_SetWorkDir() {
|
void Command_SetWorkDir() {
|
||||||
String dir = lua_tostring(LuaState, -1);
|
String dir = lua_tostring(LuaState, -1);
|
||||||
@@ -1331,7 +1332,7 @@ void Command_SetWorkDir() {
|
|||||||
void Command_SetProject() {
|
void Command_SetProject() {
|
||||||
Command_SetWorkDir();
|
Command_SetWorkDir();
|
||||||
Command_SetProjectFile();
|
Command_SetProjectFile();
|
||||||
}
|
} RegisterCommand(Command_SetProject);
|
||||||
|
|
||||||
int Lua_SetProjectFile(lua_State *L) {
|
int Lua_SetProjectFile(lua_State *L) {
|
||||||
Command_SetProjectFile();
|
Command_SetProjectFile();
|
||||||
@@ -1419,12 +1420,12 @@ String16 FetchLoadWord(void) {
|
|||||||
void Command_ToggleDebug() {
|
void Command_ToggleDebug() {
|
||||||
Window *window = GetWindow(DebugWindowID);
|
Window *window = GetWindow(DebugWindowID);
|
||||||
window->visible = !window->visible;
|
window->visible = !window->visible;
|
||||||
}
|
} RegisterCommand(Command_ToggleDebug);
|
||||||
|
|
||||||
void Command_KillProcess() {
|
void Command_KillProcess() {
|
||||||
BSet main = GetBSet(LastActiveLayoutWindowID);
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
KillProcess(main.view);
|
KillProcess(main.view);
|
||||||
}
|
} RegisterCommand(Command_KillProcess);
|
||||||
|
|
||||||
int Lua_KillProcess(lua_State *L) {
|
int Lua_KillProcess(lua_State *L) {
|
||||||
Command_KillProcess();
|
Command_KillProcess();
|
||||||
@@ -1434,7 +1435,7 @@ int Lua_KillProcess(lua_State *L) {
|
|||||||
void Command_KillWindow() {
|
void Command_KillWindow() {
|
||||||
BSet main = GetBSet(LastActiveLayoutWindowID);
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
main.window->kill = true;
|
main.window->kill = true;
|
||||||
}
|
} RegisterCommand(Command_KillWindow);
|
||||||
|
|
||||||
int Lua_KillWindow(lua_State *L) {
|
int Lua_KillWindow(lua_State *L) {
|
||||||
Command_KillWindow();
|
Command_KillWindow();
|
||||||
|
|||||||
@@ -185,3 +185,18 @@ void ReloadStyle() {
|
|||||||
StyleVCVarsall = GetStyleString("VCVarsall", StyleVCVarsall);
|
StyleVCVarsall = GetStyleString("VCVarsall", StyleVCVarsall);
|
||||||
StyleUndoMergeTimeout = GetStyleFloat("UndoMergeTimeout", StyleUndoMergeTimeout);
|
StyleUndoMergeTimeout = GetStyleFloat("UndoMergeTimeout", StyleUndoMergeTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef void CommandFunction(void);
|
||||||
|
Array<CommandFunction *> CommandFunctions;
|
||||||
|
|
||||||
|
#define STRINGIFY_(x) x
|
||||||
|
#define STRINGIFY(x) STRINGIFY_(x)
|
||||||
|
#define CONCAT_(a, b) a ## b
|
||||||
|
#define CONCAT(a, b) CONCAT_(a, b)
|
||||||
|
|
||||||
|
struct Register_Command {
|
||||||
|
Register_Command(CommandFunction *f) {
|
||||||
|
Add(&CommandFunctions, f);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#define RegisterCommand(NAME) Register_Command CONCAT(COMMAND, __COUNTER__)(NAME)
|
||||||
Reference in New Issue
Block a user