Project configs
This commit is contained in:
@@ -5,26 +5,23 @@
|
||||
- Project config
|
||||
- IndentKind has issues with stuff still like cleaning whitespace etc.
|
||||
- Remedybg commands integrated! (like clicking f5 and opening up the window)
|
||||
- Variable documentation ????? not looking too good due to formatting
|
||||
- OnUpdate view hooks!
|
||||
- Macros
|
||||
- ctrl-e started doing no-ops again ... ??
|
||||
- Window position: vscode opens in fullscreen and then remembers what position it was close in (could be a config option)
|
||||
|
||||
- OnUpdate view hooks!
|
||||
- OnSave buffer hooks which will execute the config on save
|
||||
- Make the special view hooks also available for modification and registered but maybe under different name or something
|
||||
|
||||
Use session 4
|
||||
- ListVariables instead of GenerateConfig, auto saving of variables
|
||||
- Option for inserting tab instead of space
|
||||
- Add <<File>> <<WorkDir>> template strings to Open (Then remove SEtWorkdirhere)
|
||||
- :Set Filename to name current buffer ??? :O and others like that!!
|
||||
- :Close Fuzzy search exact match doesn't match with Close
|
||||
- Setting variables maybe should create and modify config, commit these changes immediately? So user can change keybindings in command window and commit immediately
|
||||
- Make the special view hooks also available for modification and registered but maybe under different name or something
|
||||
|
||||
- Make a fuzzy command !> grep and fuzzy over it??? (doesn't seem very useful for grep)
|
||||
- Make the equivalent of SearchProject but for cmds like !@git grep -n "@>"
|
||||
- Add Bool variable
|
||||
|
||||
- RegisterCommand should_appear_in_listing variable
|
||||
- Maybe one list for all variables including the commands etc?
|
||||
|
||||
Use session 3:
|
||||
- Maybe status view, commit changes (like to buffer name or line) on enter?
|
||||
@@ -44,10 +41,9 @@ Debug session:
|
||||
- Report errorf - use coroutine dialogs
|
||||
- Replace in render layer also
|
||||
- BlockAllocator something is not working there which only showed after executing OpenCode on many files
|
||||
- Some bad allocating happening in Clipboard for sure
|
||||
- Some bad allocating happening in Clipboard for sure OR MAYBE BLOCK ALLOCATOR ACTION
|
||||
|
||||
New UI Session
|
||||
- Cleanup String16/String with Open and EvalCommands after lua refactor
|
||||
- Uneditable buffers ?
|
||||
- Maybe marked allocations??? So that we can associate allocations with a buffer or view and then dealloc all at the same time
|
||||
|
||||
|
||||
@@ -176,6 +176,10 @@ void UIMessagef(const char *fmt, ...) {
|
||||
void ReportErrorf(const char *fmt, ...) {
|
||||
Scratch scratch;
|
||||
STRING_FORMAT(scratch, fmt, string);
|
||||
if (BreakOnError) {
|
||||
BREAK();
|
||||
}
|
||||
|
||||
View *view = GetView(NullViewID);
|
||||
if (view) {
|
||||
Appendf(view, "%S\n", string);
|
||||
@@ -193,6 +197,9 @@ void ReportConsolef(const char *fmt, ...) {
|
||||
void ReportWarningf(const char *fmt, ...) {
|
||||
Scratch scratch;
|
||||
STRING_FORMAT(scratch, fmt, string);
|
||||
if (BreakOnError) {
|
||||
BREAK();
|
||||
}
|
||||
View *null_view = GetView(NullViewID);
|
||||
Appendf(null_view, "%S\n", string);
|
||||
}
|
||||
@@ -583,37 +590,6 @@ void Set(String string) {
|
||||
ReportErrorf("Failed to :Set, no such variable found: %S", name);
|
||||
}
|
||||
|
||||
void EvalCommandsLineByLine(BSet set) {
|
||||
WindowID save_last = PrimaryWindowID;
|
||||
WindowID save_active = ActiveWindowID;
|
||||
WindowID save_next = NextActiveWindowID;
|
||||
Caret save_caret = set.view->carets[0];
|
||||
ActiveWindowID = set.window->id;
|
||||
PrimaryWindowID = set.window->id;
|
||||
NextActiveWindowID = set.window->id;
|
||||
for (Int i = 0; i < set.buffer->line_starts.len; i += 1) {
|
||||
Range range = GetLineRangeWithoutNL(set.buffer, i);
|
||||
String16 string = GetString(set.buffer, range);
|
||||
string = Trim(string);
|
||||
if (string.len == 0) {
|
||||
continue;
|
||||
}
|
||||
if (StartsWith(string, u"//")) {
|
||||
continue;
|
||||
}
|
||||
Open(string);
|
||||
}
|
||||
set.view->carets[0] = save_caret;
|
||||
PrimaryWindowID = save_last;
|
||||
ActiveWindowID = save_active;
|
||||
NextActiveWindowID = save_next;
|
||||
}
|
||||
|
||||
void CMD_EvalCommandsLineByLine() {
|
||||
BSet set = GetBSet(PrimaryWindowID);
|
||||
EvalCommandsLineByLine(set);
|
||||
} RegisterCommand(CMD_EvalCommandsLineByLine, "", "Goes line by line over a buffer and evaluates every line as a command, ignores empty or lines starting with '//'");
|
||||
|
||||
ResolvedOpen ResolveOpen(Allocator alo, String path, ResolveOpenMeta meta) {
|
||||
ResolvedOpen result = {};
|
||||
path = Trim(path);
|
||||
|
||||
@@ -285,3 +285,81 @@ void TestParser() {
|
||||
|
||||
|
||||
} RegisterFunction(&TestFunctions, TestParser);
|
||||
|
||||
|
||||
void CMD_OpenConfig() {
|
||||
Buffer *buffer = GetBuffer(GlobalConfigBufferID);
|
||||
Open(buffer->name);
|
||||
} RegisterCommand(CMD_OpenConfig, "", "Open the global config file");
|
||||
|
||||
void CMD_OpenConfigOptions() {
|
||||
if (ActiveWindowID == CommandWindowID && LastExecutedManualCommand == CMD_OpenConfigOptions) {
|
||||
NextActiveWindowID = PrimaryWindowID;
|
||||
return;
|
||||
}
|
||||
ProfileFunction();
|
||||
|
||||
BSet command_bar = GetBSet(CommandWindowID);
|
||||
command_bar.window->visible = true;
|
||||
NextActiveWindowID = command_bar.window->id;
|
||||
ResetBuffer(command_bar.buffer);
|
||||
For (Variables) {
|
||||
RawAppendf(command_bar.buffer, "\n:Set %-50S ", it.name);
|
||||
switch(it.type) {
|
||||
case VariableType_Color: RawAppendf(command_bar.buffer, "%x", it.color->value); break;
|
||||
case VariableType_String: RawAppendf(command_bar.buffer, "'%S'", *it.string); break;
|
||||
case VariableType_Int: RawAppendf(command_bar.buffer, "%lld", (long long)*it.i); break;
|
||||
case VariableType_Float: RawAppendf(command_bar.buffer, "%f", *it.f); break;
|
||||
default: InvalidCodepath();
|
||||
}
|
||||
}
|
||||
For (CommandFunctions) {
|
||||
RawAppendf(command_bar.buffer, "\n:Set %-50S '%S'", it.name, it.binding);
|
||||
}
|
||||
command_bar.view->update_scroll = true;
|
||||
SelectRange(command_bar.view, GetBufferBeginAsRange(command_bar.buffer));
|
||||
} RegisterCommand(CMD_OpenConfigOptions, "", "List available variables and associated documentation inside the command window");
|
||||
|
||||
void EvalCommandsLineByLine(BSet set) {
|
||||
WindowID save_last = PrimaryWindowID;
|
||||
WindowID save_active = ActiveWindowID;
|
||||
WindowID save_next = NextActiveWindowID;
|
||||
Caret save_caret = set.view->carets[0];
|
||||
ActiveWindowID = set.window->id;
|
||||
PrimaryWindowID = set.window->id;
|
||||
NextActiveWindowID = set.window->id;
|
||||
for (Int i = 0; i < set.buffer->line_starts.len; i += 1) {
|
||||
Range range = GetLineRangeWithoutNL(set.buffer, i);
|
||||
String16 string = GetString(set.buffer, range);
|
||||
string = Trim(string);
|
||||
if (string.len == 0) {
|
||||
continue;
|
||||
}
|
||||
if (StartsWith(string, u"//")) {
|
||||
continue;
|
||||
}
|
||||
Open(string);
|
||||
}
|
||||
set.view->carets[0] = save_caret;
|
||||
PrimaryWindowID = save_last;
|
||||
ActiveWindowID = save_active;
|
||||
NextActiveWindowID = save_next;
|
||||
}
|
||||
|
||||
void CMD_EvalCommandsLineByLine() {
|
||||
BSet set = GetBSet(PrimaryWindowID);
|
||||
EvalCommandsLineByLine(set);
|
||||
} RegisterCommand(CMD_EvalCommandsLineByLine, "", "Goes line by line over a buffer and evaluates every line as a command, ignores empty or lines starting with '//'");
|
||||
|
||||
BufferID LoadConfig(String config_path) {
|
||||
ReportConsolef("Loading config %S...", config_path);
|
||||
Window *window = GetWindow(NullWindowID);
|
||||
View *view = WindowOpenBufferView(window, config_path);
|
||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||
buffer->special = true;
|
||||
EvalCommandsLineByLine({window, view, buffer});
|
||||
if (window->active_view == view->id) {
|
||||
window->active_view = NullViewID;
|
||||
}
|
||||
return buffer->id;
|
||||
}
|
||||
@@ -8,6 +8,7 @@ bool WaitForEventsState = true;
|
||||
bool RunGCThisFrame;
|
||||
bool SearchCaseSensitive = false;
|
||||
bool SearchWordBoundary = false;
|
||||
bool BreakOnError = true;
|
||||
|
||||
WindowID WindowIDs;
|
||||
ViewID ViewIDs;
|
||||
@@ -22,7 +23,6 @@ BufferID NullBufferID;
|
||||
ViewID NullViewID;
|
||||
WindowID NullWindowID;
|
||||
|
||||
|
||||
// hidden floating window
|
||||
WindowID DebugWindowID;
|
||||
ViewID DebugViewID;
|
||||
@@ -163,7 +163,7 @@ RegisterVariable(String, WindowsVCVarsPathToLoadDevEnviroment, "C:/Program Files
|
||||
RegisterVariable(Float, UndoMergeTime, 0.3);
|
||||
RegisterVariable(Float, JumpHistoryMergeTime, 0.3);
|
||||
RegisterVariable(String, InternetBrowser, "firefox");
|
||||
RegisterVariable(String, OpenCodeCommandExcludePatterns, ".git/|.obj|.o|.pdb|.exe|.ilk|.ttf|.ico|.gif|.jpg|.png|.spall|.dll|.so|.a|.lib");
|
||||
RegisterVariable(String, OpenCodeCommandExcludePatterns, ".git/|.obj|.o|.pdb|.exe|.ilk|.ttf|.ico|.gif|.jpg|.png|.spall|.dll|.so|.a|.lib|SDL/");
|
||||
RegisterVariable(Int, TrimTrailingWhitespace, 1);
|
||||
RegisterVariable(Int, FormatCode, 0);
|
||||
RegisterVariable(Int, SetModifiesConfig, 1);
|
||||
@@ -896,25 +896,20 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
String project_config = {};
|
||||
for (int i = 1; i < argc; i += 1) {
|
||||
String it = argv[i];
|
||||
if (EndsWith(it, ".te")) {
|
||||
project_config = it;
|
||||
}
|
||||
Open(argv[i]);
|
||||
}
|
||||
|
||||
{
|
||||
Scratch scratch;
|
||||
String exe_dir = GetExeDir(scratch);
|
||||
String config_path = Format(scratch, "%S/config.te", exe_dir);
|
||||
Window *window = GetWindow(NullWindowID);
|
||||
View *view = WindowOpenBufferView(window, config_path);
|
||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||
buffer->special = true;
|
||||
GlobalConfigBufferID = buffer->id;
|
||||
EvalCommandsLineByLine({window, view, buffer});
|
||||
if (window->active_view == view->id) {
|
||||
window->active_view = NullViewID;
|
||||
GlobalConfigBufferID = LoadConfig(Format(scratch, "%S/config.te", GetExeDir(scratch)));
|
||||
if (project_config.len) {
|
||||
LoadConfig(project_config);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ReportConsolef(":Set WorkDir '%S'", WorkDir);
|
||||
if (Testing) InitTests();
|
||||
|
||||
@@ -23,39 +23,6 @@ void CMD_ShowCommands() {
|
||||
SelectRange(command_bar.view, GetBufferBeginAsRange(command_bar.buffer));
|
||||
} RegisterCommand(CMD_ShowCommands, "ctrl-shift-p", "List available commands and their documentation inside the command window");
|
||||
|
||||
void CMD_OpenConfig() {
|
||||
Buffer *buffer = GetBuffer(GlobalConfigBufferID);
|
||||
Open(buffer->name);
|
||||
} RegisterCommand(CMD_OpenConfig, "", "Open the global config file");
|
||||
|
||||
void CMD_OpenConfigOptions() {
|
||||
if (ActiveWindowID == CommandWindowID && LastExecutedManualCommand == CMD_OpenConfigOptions) {
|
||||
NextActiveWindowID = PrimaryWindowID;
|
||||
return;
|
||||
}
|
||||
ProfileFunction();
|
||||
|
||||
BSet command_bar = GetBSet(CommandWindowID);
|
||||
command_bar.window->visible = true;
|
||||
NextActiveWindowID = command_bar.window->id;
|
||||
ResetBuffer(command_bar.buffer);
|
||||
For (Variables) {
|
||||
RawAppendf(command_bar.buffer, "\n:Set %-50S ", it.name);
|
||||
switch(it.type) {
|
||||
case VariableType_Color: RawAppendf(command_bar.buffer, "%x", it.color->value); break;
|
||||
case VariableType_String: RawAppendf(command_bar.buffer, "'%S'", *it.string); break;
|
||||
case VariableType_Int: RawAppendf(command_bar.buffer, "%lld", (long long)*it.i); break;
|
||||
case VariableType_Float: RawAppendf(command_bar.buffer, "%f", *it.f); break;
|
||||
default: InvalidCodepath();
|
||||
}
|
||||
}
|
||||
For (CommandFunctions) {
|
||||
RawAppendf(command_bar.buffer, "\n:Set %-50S '%S'", it.name, it.binding);
|
||||
}
|
||||
command_bar.view->update_scroll = true;
|
||||
SelectRange(command_bar.view, GetBufferBeginAsRange(command_bar.buffer));
|
||||
} RegisterCommand(CMD_OpenConfigOptions, "", "List available variables and associated documentation inside the command window");
|
||||
|
||||
void CMD_ShowDebugBufferList() {
|
||||
if (ActiveWindowID == CommandWindowID && LastExecutedManualCommand == CMD_ShowDebugBufferList) {
|
||||
NextActiveWindowID = PrimaryWindowID;
|
||||
|
||||
Reference in New Issue
Block a user