Rename to Config, Fix slowness of ShowCommands and improve quality
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
- What precise workflow do I need for me to be viable to use this?
|
||||
- From a user (novice) point of view, how does it look like?
|
||||
|
||||
- Remove LUA and replace with keybindings, config, commands
|
||||
- "DO YOU REALLY WANT TO QUIT?" popup
|
||||
- open all in the folder and ctrl + p like in VSCode (without special buffers)
|
||||
- Guide on the first page for new users with links to configs, tutorials
|
||||
|
||||
@@ -150,7 +150,7 @@ void Test(mco_coro *co) {
|
||||
}
|
||||
|
||||
void InitTests() {
|
||||
StyleWaitForEvents = false;
|
||||
ConfigWaitForEvents = false;
|
||||
TestDir = Format(TestArena, "%S/test_env", GetExeDir(TestArena));
|
||||
CoAdd(Test);
|
||||
}
|
||||
|
||||
@@ -1005,7 +1005,7 @@ API void UndoEdit(Buffer *buffer, Array<Caret> *carets) {
|
||||
|
||||
if (buffer->undo_stack.len > 0) {
|
||||
HistoryEntry *next = GetLast(buffer->undo_stack);
|
||||
if (entry.time - next->time <= StyleUndoMergeTimeout) {
|
||||
if (entry.time - next->time <= ConfigUndoMergeTimeout) {
|
||||
UndoEdit(buffer, carets);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -718,14 +718,14 @@ void Command_Undo() {
|
||||
} RegisterCommand(Command_Undo, "ctrl-z");
|
||||
|
||||
void Command_MakeFontLarger() {
|
||||
StyleFontSize += 1;
|
||||
ReloadFont(StyleFont, (U32)StyleFontSize);
|
||||
ConfigFontSize += 1;
|
||||
ReloadFont(ConfigFont, (U32)ConfigFontSize);
|
||||
} RegisterCommand(Command_MakeFontLarger, "ctrl-equals");
|
||||
|
||||
void Command_MakeFontSmaller() {
|
||||
if (StyleFontSize > 4) {
|
||||
StyleFontSize -= 1;
|
||||
ReloadFont(StyleFont, (U32)StyleFontSize);
|
||||
if (ConfigFontSize > 4) {
|
||||
ConfigFontSize -= 1;
|
||||
ReloadFont(ConfigFont, (U32)ConfigFontSize);
|
||||
}
|
||||
} RegisterCommand(Command_MakeFontSmaller, "ctrl-minus");
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ String AsString(Lexer *lex) {
|
||||
}
|
||||
|
||||
void EatWhitespace(Lexer *lex) {
|
||||
while (IsWhitespace(At(lex))) {
|
||||
while (At(lex) != '\n' && IsWhitespace(At(lex))) {
|
||||
Advance(lex);
|
||||
}
|
||||
}
|
||||
@@ -74,6 +74,7 @@ String Intern(InternTable *table, String string) {
|
||||
// optimize worst offenders (like event text)
|
||||
InternTable GlobalInternTable;
|
||||
|
||||
Function *LastExecutedCommand;
|
||||
Array<CommandData> CommandFunctions;
|
||||
Array<FunctionData> TestFunctions;
|
||||
Array<Variable> Variables;
|
||||
@@ -143,13 +144,13 @@ RegisterVariable(Color, ColorTitleBarActiveBackground, {0xfe, 0xfe, 0xfe, 0xfe})
|
||||
RegisterVariable(Color, ColorTitleBarSelection, GruvboxLight3);
|
||||
RegisterVariable(Color, ColorResizerBackground, GruvboxLight0Hard);
|
||||
RegisterVariable(Color, ColorResizerOutline, GruvboxLight3);
|
||||
RegisterVariable(Int, StyleWaitForEvents, 1);
|
||||
RegisterVariable(Int, StyleDrawLineNumbers, 1);
|
||||
RegisterVariable(Int, StyleDrawScrollbar, 1);
|
||||
RegisterVariable(Int, StyleIndentSize, 4);
|
||||
RegisterVariable(Int, StyleFontSize, 15);
|
||||
RegisterVariable(Int, StyleFontFilter, 0);
|
||||
RegisterVariable(String, StyleFont, "/home/krz/text_editor/package/CascadiaMono.ttf");
|
||||
RegisterVariable(String, StyleVCVarsall, "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvars64.bat");
|
||||
RegisterVariable(Float, StyleUndoMergeTimeout, 0.3);
|
||||
RegisterVariable(Int, ConfigWaitForEvents, 1);
|
||||
RegisterVariable(Int, ConfigDrawLineNumbers, 1);
|
||||
RegisterVariable(Int, ConfigDrawScrollbar, 1);
|
||||
RegisterVariable(Int, ConfigIndentSize, 4);
|
||||
RegisterVariable(Int, ConfigFontSize, 15);
|
||||
RegisterVariable(Int, ConfigFontFilter, 0);
|
||||
RegisterVariable(String, ConfigFont, "/home/krz/text_editor/package/CascadiaMono.ttf");
|
||||
RegisterVariable(String, ConfigVCVarsall, "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvars64.bat");
|
||||
RegisterVariable(Float, ConfigUndoMergeTimeout, 0.3);
|
||||
RegisterVariable(String, ConfigInternetBrowser, "firefox");
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
#include "process.cpp"
|
||||
#include "event.cpp"
|
||||
#include "parser.cpp"
|
||||
#include "config.cpp"
|
||||
|
||||
#include "commands.cpp"
|
||||
#include "commands_clipboard.cpp"
|
||||
@@ -392,7 +392,10 @@ void OnCommand(Event event) {
|
||||
|
||||
For (CommandFunctions) {
|
||||
if (it.trigger && MatchEvent(it.trigger, &event)) {
|
||||
double start = GetTimeSeconds();
|
||||
it.function();
|
||||
ReportConsolef("%S: %f", it.name, GetTimeSeconds() - start);
|
||||
LastExecutedCommand = it.function;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -520,7 +523,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", StyleVCVarsall);
|
||||
String cmd = Format(scratch, "\"%S\" && set", ConfigVCVarsall);
|
||||
view = ExecHidden(buffer_name, cmd, working_dir);
|
||||
}
|
||||
for (;;) {
|
||||
@@ -568,7 +571,7 @@ void MainLoop() {
|
||||
Update(it);
|
||||
}
|
||||
|
||||
WaitForEvents = StyleWaitForEvents;
|
||||
WaitForEvents = ConfigWaitForEvents;
|
||||
if (IsDocumentSelectionValid() || IsScrollbarSelectionValid() || ActiveProcesses.len) {
|
||||
WaitForEvents = false;
|
||||
}
|
||||
@@ -710,7 +713,7 @@ int main(int argc, char **argv)
|
||||
|
||||
InitBuffers();
|
||||
InitRender();
|
||||
ReloadFont(StyleFont, (U32)StyleFontSize);
|
||||
ReloadFont(ConfigFont, (U32)ConfigFontSize);
|
||||
InitWindows();
|
||||
InitOS(ReportWarningf);
|
||||
|
||||
|
||||
@@ -403,9 +403,9 @@ void Delete(View *view, int direction, bool ctrl = false) {
|
||||
Range indent_range = GetIndentRangeAtPos(buffer, it.range.min);
|
||||
if (ctrl == false && it.range.min > indent_range.min && it.range.max <= indent_range.max) {
|
||||
Int offset = it.range.min - indent_range.min;
|
||||
Int to_delete = (offset % (StyleIndentSize));
|
||||
if (to_delete == 0) to_delete = StyleIndentSize;
|
||||
to_delete = Clamp(to_delete, (Int)1, StyleIndentSize);
|
||||
Int to_delete = (offset % (ConfigIndentSize));
|
||||
if (to_delete == 0) to_delete = ConfigIndentSize;
|
||||
to_delete = Clamp(to_delete, (Int)1, ConfigIndentSize);
|
||||
for (Int i = 0; i < to_delete; i += 1) {
|
||||
it = MoveCaret(buffer, it, direction, false, SHIFT_PRESS);
|
||||
}
|
||||
@@ -472,12 +472,12 @@ void IndentSelectedLines(View *view, bool shift = false) {
|
||||
Range pos_range_of_line = GetLineRange(buffer, i);
|
||||
|
||||
if (!shift) {
|
||||
String16 whitespace_string = {u" ", StyleIndentSize};
|
||||
String16 whitespace_string = {u" ", ConfigIndentSize};
|
||||
AddEdit(&edits, {pos_range_of_line.min, pos_range_of_line.min}, whitespace_string);
|
||||
} else {
|
||||
String16 string = GetString(buffer, pos_range_of_line);
|
||||
Int whitespace_len = 0;
|
||||
for (Int i = 0; i < StyleIndentSize && i < string.len && string.data[i] == ' '; i += 1) {
|
||||
for (Int i = 0; i < ConfigIndentSize && i < string.len && string.data[i] == ' '; i += 1) {
|
||||
whitespace_len += 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ Window *CreateWind() {
|
||||
w->font = &PrimaryFont;
|
||||
w->visible = true;
|
||||
w->layout = true;
|
||||
w->draw_scrollbar = StyleDrawScrollbar;
|
||||
w->draw_line_numbers = StyleDrawLineNumbers;
|
||||
w->draw_scrollbar = ConfigDrawScrollbar;
|
||||
w->draw_line_numbers = ConfigDrawLineNumbers;
|
||||
w->draw_line_highlight = true;
|
||||
w->jump_history = true;
|
||||
w->id = AllocWindowID(w);
|
||||
@@ -257,7 +257,7 @@ void GotoBackward(Window *window) {
|
||||
|
||||
if (window->goto_history.len) {
|
||||
GotoCrumb *next = GetLast(window->goto_history);
|
||||
if (c.time - next->time <= StyleUndoMergeTimeout) {
|
||||
if (c.time - next->time <= ConfigUndoMergeTimeout) {
|
||||
GotoBackward(window);
|
||||
}
|
||||
}
|
||||
@@ -277,7 +277,7 @@ void GotoForward(Window *window) {
|
||||
|
||||
if (window->goto_redo.len) {
|
||||
GotoCrumb *next = GetLast(window->goto_redo);
|
||||
if (c.time - next->time <= StyleUndoMergeTimeout) {
|
||||
if (c.time - next->time <= ConfigUndoMergeTimeout) {
|
||||
GotoForward(window);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,19 +55,29 @@ void CommandWindowUpdate() {
|
||||
}
|
||||
|
||||
void Command_ShowCommands() {
|
||||
if (ActiveWindowID == CommandBarWindowID && LastExecutedCommand == Command_ShowCommands) {
|
||||
ActiveWindowID = LastActiveLayoutWindowID;
|
||||
return;
|
||||
}
|
||||
|
||||
BSet command_bar = GetBSet(CommandBarWindowID);
|
||||
command_bar.window->visible = true;
|
||||
command_bar.window->eval_command = true;
|
||||
ActiveWindowID = command_bar.window->id;
|
||||
ResetBuffer(command_bar.buffer);
|
||||
For(CommandFunctions) {
|
||||
Appendf(command_bar.view, "%S\n", it.name);
|
||||
RawAppendf(command_bar.buffer, "%S\n", it.name);
|
||||
}
|
||||
command_bar.view->update_scroll = true;
|
||||
SelectRange(command_bar.view, GetBufferEndAsRange(command_bar.buffer));
|
||||
} RegisterCommand(Command_ShowCommands, "ctrl-shift-p");
|
||||
|
||||
void Command_ShowBufferList() {
|
||||
if (ActiveWindowID == CommandBarWindowID && LastExecutedCommand == Command_ShowBufferList) {
|
||||
ActiveWindowID = LastActiveLayoutWindowID;
|
||||
return;
|
||||
}
|
||||
|
||||
BSet command_bar = GetBSet(CommandBarWindowID);
|
||||
command_bar.window->visible = true;
|
||||
command_bar.window->eval_command = false;
|
||||
|
||||
Reference in New Issue
Block a user