Misc improvements and add config.te
This commit is contained in:
@@ -2,10 +2,15 @@
|
||||
! From a user (novice) point of view, how does it look like?
|
||||
|
||||
- We need regex for: [FormatCode matching, IsCode matching,
|
||||
- Variable documentation
|
||||
- Project configuration (the semantics: pass through command line (don't like simply open in dir) or use command to open?)
|
||||
- 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!
|
||||
- JumpHistory maybe a smarter algorithm is needed, like accept only if line also changed
|
||||
- Macros
|
||||
- ctrl-shift-f should insert the selected into search
|
||||
- jump history batching doesn't work ...
|
||||
|
||||
Use session 4
|
||||
- ListVariables instead of GenerateConfig, auto saving of variables
|
||||
|
||||
@@ -105,6 +105,7 @@ Glyph *GetGlyph(Font *font, uint32_t codepoint) {
|
||||
return &font->glyphs[index];
|
||||
}
|
||||
}
|
||||
|
||||
Font CreateFont(Atlas *atlas, int32_t size, String path) {
|
||||
Allocator allocator = GetSystemAllocator();
|
||||
Scratch scratch;
|
||||
|
||||
@@ -547,12 +547,11 @@ void Set(String string) {
|
||||
} ElseInvalidCodepath();
|
||||
|
||||
|
||||
if (name == "FontSize" || name == "Font") {
|
||||
ReloadFont(Font, (U32)FontSize);
|
||||
if (name == "FontSize" || name == "PathToFont") {
|
||||
ReloadFont(PathToFont, (U32)FontSize);
|
||||
} else if (name == "WorkDir") {
|
||||
SetWorkDirHere(*var->string);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1150,13 +1149,13 @@ void CMD_Undo() {
|
||||
|
||||
void CMD_MakeFontLarger() {
|
||||
FontSize += 1;
|
||||
ReloadFont(Font, (U32)FontSize);
|
||||
ReloadFont(PathToFont, (U32)FontSize);
|
||||
} RegisterCommand(CMD_MakeFontLarger, "ctrl-equals", "Increase the font size");
|
||||
|
||||
void CMD_MakeFontSmaller() {
|
||||
if (FontSize > 4) {
|
||||
FontSize -= 1;
|
||||
ReloadFont(Font, (U32)FontSize);
|
||||
ReloadFont(PathToFont, (U32)FontSize);
|
||||
}
|
||||
} RegisterCommand(CMD_MakeFontSmaller, "ctrl-minus", "Decrease the font size");
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ WindowID BuildWindowID;
|
||||
ViewID BuildViewID;
|
||||
BufferID BuildBufferID;
|
||||
BufferID SearchProjectBufferID;
|
||||
BufferID GlobalConfigBufferID;
|
||||
|
||||
WindowID NextActiveWindowID;
|
||||
WindowID ActiveWindowID;
|
||||
@@ -154,14 +155,15 @@ RegisterVariable(Int, WaitForEvents, 1);
|
||||
RegisterVariable(Int, DrawLineNumbers, 1);
|
||||
RegisterVariable(Int, DrawScrollbar, 1);
|
||||
RegisterVariable(Int, IndentSize, 4);
|
||||
RegisterVariable(String, IndentKind, "spaces");
|
||||
RegisterVariable(String, IndentKindWhichIsTabsOrSpaces, "spaces");
|
||||
RegisterVariable(Int, FontSize, 15);
|
||||
RegisterVariable(String, WorkDir, "");
|
||||
RegisterVariable(String, Font, "");
|
||||
RegisterVariable(String, VCVarsall, "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvars64.bat");
|
||||
RegisterVariable(String, PathToFont, "");
|
||||
RegisterVariable(String, WindowsVCVarsPathToLoadDevEnviroment, "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvars64.bat");
|
||||
RegisterVariable(Float, UndoMergeTime, 0.3);
|
||||
RegisterVariable(Float, JumpHistoryMergeTime, 0.3);
|
||||
RegisterVariable(String, InternetBrowser, "firefox");
|
||||
RegisterVariable(String, NonCodePatterns_EndsWith, ".git/|.obj|.o|.pdb|.exe|.ilk|.ttf|.ico|.gif|.jpg|.png|.spall|.dll|.so|.a|.lib");
|
||||
RegisterVariable(Int, TrimTrailingWhitespace, 1);
|
||||
RegisterVariable(Int, FormatCode, 0);
|
||||
RegisterVariable(Int, FormatCode, 0);
|
||||
RegisterVariable(Int, SetModifiesConfig, 1);
|
||||
@@ -676,7 +676,7 @@ void Windows_SetupVCVarsall(mco_coro *co) {
|
||||
Scratch scratch;
|
||||
String working_dir = WorkDir;
|
||||
String buffer_name = GetUniqueBufferName(working_dir, "vcvarsall-");
|
||||
String cmd = Format(scratch, "\"%S\" && set", VCVarsall);
|
||||
String cmd = Format(scratch, "\"%S\" && set", WindowsVCVarsPathToLoadDevEnviroment);
|
||||
view = ExecHidden(buffer_name, cmd, working_dir);
|
||||
}
|
||||
for (;;) {
|
||||
@@ -874,7 +874,7 @@ int main(int argc, char **argv)
|
||||
|
||||
InitBuffers();
|
||||
InitRender();
|
||||
ReloadFont(Font, (U32)FontSize);
|
||||
ReloadFont(PathToFont, (U32)FontSize);
|
||||
InitWindows();
|
||||
InitOS(ReportWarningf);
|
||||
|
||||
@@ -895,13 +895,9 @@ int main(int argc, char **argv)
|
||||
Window *window = GetWindow(NullWindowID);
|
||||
View *view = WindowOpenBufferView(window, config_path);
|
||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||
bool file_exists = buffer->file_mod_time != 0;
|
||||
if (!file_exists) {
|
||||
GenerateConfig(view);
|
||||
} else {
|
||||
EvalCommandsLineByLine({window, view, buffer});
|
||||
}
|
||||
buffer->dirty = false;
|
||||
buffer->special = true;
|
||||
GlobalConfigBufferID = buffer->id;
|
||||
EvalCommandsLineByLine({window, view, buffer});
|
||||
if (window->active_view == view->id) {
|
||||
window->active_view = NullViewID;
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ struct Variable {
|
||||
|
||||
struct Register_Variable {
|
||||
Register_Variable(Array<Variable> *variables, VariableType type, String name, void *addr) {
|
||||
Add(variables, {type, name, addr});
|
||||
Add(variables, {type, name, {addr}});
|
||||
}
|
||||
};
|
||||
#define RegisterVariable(type, name, ...) \
|
||||
@@ -199,6 +199,7 @@ struct ResolvedOpen {
|
||||
Int line, col;
|
||||
bool existing_buffer;
|
||||
};
|
||||
|
||||
ResolvedOpen ResolveOpen(Allocator scratch, String path, ResolveOpenMeta meta);
|
||||
BSet Open(String path, ResolveOpenMeta meta = ResolveOpenMeta_Normal);
|
||||
BSet Open(String16 path, ResolveOpenMeta meta = ResolveOpenMeta_Normal);
|
||||
|
||||
@@ -508,12 +508,12 @@ Array<Range> GetSelectedLinesSorted(Allocator allocator, View *view) {
|
||||
|
||||
char16_t GetIndentChar() {
|
||||
char16_t c = u' ';
|
||||
if (IndentKind == "spaces") {
|
||||
if (IndentKindWhichIsTabsOrSpaces == "spaces") {
|
||||
c = u' ';
|
||||
} else if (IndentKind == "tabs") {
|
||||
} else if (IndentKindWhichIsTabsOrSpaces == "tabs") {
|
||||
c = u'\t';
|
||||
} else {
|
||||
ReportErrorf("Invalid IndentKind value: %S", IndentKind);
|
||||
ReportErrorf("Invalid IndentKindWhichIsTabsOrSpaces value: %S", IndentKindWhichIsTabsOrSpaces);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,18 @@ struct View;
|
||||
struct ViewID { Int id; View *o; };
|
||||
|
||||
typedef void Function();
|
||||
struct FunctionData { String name; Function *function; };
|
||||
struct CommandData { String name; String binding; Function *function; String doc; struct Trigger *trigger; };
|
||||
struct FunctionData {
|
||||
String name;
|
||||
Function *function;
|
||||
};
|
||||
|
||||
struct CommandData {
|
||||
String name;
|
||||
String binding;
|
||||
Function *function;
|
||||
String doc;
|
||||
struct Trigger *trigger;
|
||||
};
|
||||
|
||||
enum ViewKind {
|
||||
ViewKind_Normal,
|
||||
|
||||
@@ -13,15 +13,49 @@ void CMD_ShowCommands() {
|
||||
if (it.name == "OpenCommand") {
|
||||
continue;
|
||||
}
|
||||
RawAppendf(command_bar.buffer, "\n:%-30S <|| :Set %-30S '%-30S'", it.name, it.name, it.binding);
|
||||
// RawAppendf(command_bar.buffer, "\n:%-30S <|| :Set %-30S '%-30S'", it.name, it.name, it.binding);
|
||||
RawAppendf(command_bar.buffer, "\n:%-30S <|| ", it.name);
|
||||
if (it.doc.len) {
|
||||
RawAppendf(command_bar.buffer, " |::| %S", it.doc);
|
||||
RawAppendf(command_bar.buffer, "%S", it.doc);
|
||||
}
|
||||
}
|
||||
command_bar.view->update_scroll = true;
|
||||
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