Compare commits
4 Commits
f646a6d22c
...
146273afd8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
146273afd8 | ||
|
|
8f4d3a218f | ||
|
|
8c0c9c82f1 | ||
|
|
d694a374d6 |
@@ -2,13 +2,14 @@
|
||||
! From a user (novice) point of view, how does it look like?
|
||||
|
||||
- We need regex for: [FormatCode matching, IsCode matching,
|
||||
- Project config
|
||||
- IndentKind has issues with stuff still like cleaning whitespace etc.
|
||||
- Remedybg commands integrated! (like clicking f5 and opening up the window)
|
||||
- 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)
|
||||
- On Linux: Try to implement is_debugger_present()
|
||||
- Probably shouldn't emit (Key pressed when ctrl etc. is not clicked!!)
|
||||
- Brace, bracket, paren indenting?
|
||||
|
||||
- OnUpdate view hooks!
|
||||
- OnSave buffer hooks which will execute the config on save
|
||||
|
||||
@@ -49,7 +49,7 @@ struct Buffer {
|
||||
|
||||
struct FuzzyPair {
|
||||
int32_t index;
|
||||
int32_t rating;
|
||||
float rating;
|
||||
};
|
||||
|
||||
enum {
|
||||
|
||||
@@ -832,20 +832,34 @@ void CMD_SetWorkDirHere() {
|
||||
} RegisterCommand(CMD_SetWorkDirHere, "", "Sets work directory to the directory of the current buffer, it also renames couple special buffers to make them accomodate the new WorkDir");
|
||||
|
||||
void Coro_OpenCode(mco_coro *co) {
|
||||
Array<String> patterns = Split(CoCurr->arena, OpenCodeCommandExcludePatterns, "|");
|
||||
Array<String> patterns = SplitWhitespace(CoCurr->arena, OpenCodePatterns);
|
||||
Array<String> exclude_patterns = SplitWhitespace(CoCurr->arena, OpenCodeExcludePatterns);
|
||||
Array<String> dirs = {CoCurr->arena};
|
||||
String *param_dir = (String *)CoCurr->user_ctx;
|
||||
Add(&dirs, *param_dir);
|
||||
for (int diri = 0; diri < dirs.len; diri += 1) {
|
||||
for (FileIter it = IterateFiles(CoCurr->arena, dirs[diri]); IsValid(it); Advance(&it)) {
|
||||
bool match = false;
|
||||
ForItem (ending, patterns) {
|
||||
bool should_open = true;
|
||||
if (!it.is_directory) {
|
||||
should_open = false;
|
||||
ForItem (ending, patterns) {
|
||||
if (EndsWith(it.absolute_path, ending)) {
|
||||
should_open = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ForItem (ending, exclude_patterns) {
|
||||
if (EndsWith(it.absolute_path, ending)) {
|
||||
match = true;
|
||||
should_open = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (match) continue;
|
||||
|
||||
if (!should_open) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (it.is_directory) {
|
||||
|
||||
@@ -290,31 +290,22 @@ void CMD_OpenConfig() {
|
||||
} 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);
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
JumpTempBuffer(&main);
|
||||
NextActiveWindowID = main.window->id;
|
||||
For (Variables) {
|
||||
RawAppendf(command_bar.buffer, "\n:Set %-50S ", it.name);
|
||||
RawAppendf(main.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;
|
||||
case VariableType_Color: RawAppendf(main.buffer, "%x", it.color->value); break;
|
||||
case VariableType_String: RawAppendf(main.buffer, "'%S'", *it.string); break;
|
||||
case VariableType_Int: RawAppendf(main.buffer, "%lld", (long long)*it.i); break;
|
||||
case VariableType_Float: RawAppendf(main.buffer, "%f", *it.f); break;
|
||||
default: InvalidCodepath();
|
||||
}
|
||||
}
|
||||
For (CommandFunctions) {
|
||||
RawAppendf(command_bar.buffer, "\n:Set %-50S '%S'", it.name, it.binding);
|
||||
RawAppendf(main.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) {
|
||||
|
||||
@@ -167,7 +167,8 @@ 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|SDL/");
|
||||
RegisterVariable(String, OpenCodePatterns, ".c .h .cpp .hpp .cc .cxx .rs .go .zig .py .lua .js .ts .jsx .tsx .java .kt .swift .cs .rb .php .html .css .scss .sh .bash .zsh .sql .asm .s .cmake .make .json .yaml .toml .ini .txt .md .rst .Makefile .Dockerfile .gitignore .bashrc .zshrc");
|
||||
RegisterVariable(String, OpenCodeExcludePatterns, "");
|
||||
RegisterVariable(Int, TrimTrailingWhitespace, 1);
|
||||
RegisterVariable(Int, FormatCode, 0);
|
||||
RegisterVariable(Int, SetModifiesConfig, 1);
|
||||
@@ -95,26 +95,48 @@ void CommandWindowLayout(Rect2I *rect, Int wx, Int wy) {
|
||||
n->document_rect = n->total_rect = CutBottom(rect, barsize);
|
||||
}
|
||||
|
||||
int32_t FuzzyRate(String16 string, String16 with) {
|
||||
ProfileFunction();
|
||||
if (with.len == 0) return 0;
|
||||
int32_t points = 0;
|
||||
int32_t consecutive = 0;
|
||||
int32_t with_i = 0;
|
||||
for (int32_t i = 0; i < string.len; i++) {
|
||||
if (ToLowerCase(string.data[i]) == ToLowerCase(with[with_i])) {
|
||||
consecutive += 1;
|
||||
with_i += 1;
|
||||
} else {
|
||||
with_i = 0;
|
||||
points += consecutive * consecutive;
|
||||
consecutive = 0;
|
||||
float NewFuzzyRate(String16 s, String16 p) {
|
||||
float score = 0;
|
||||
// try to do this: https://github.com/junegunn/fzf/blob/master/src/algo/algo.go
|
||||
return score;
|
||||
}
|
||||
|
||||
float FuzzyRate(String16 s, String16 p) {
|
||||
float score = 0;
|
||||
for (Int outer_pi = 0; outer_pi < p.len; outer_pi += 1) {
|
||||
String16 pit = Skip(p, outer_pi);
|
||||
if (IsWhitespace(At(pit, 0))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (with_i >= with.len) with_i = 0;
|
||||
float matching = 0;
|
||||
for (Int outer_si = 0; outer_si < s.len; outer_si += 1) {
|
||||
String16 sit = Skip(s, outer_si);
|
||||
if (IsWhitespace(At(sit, 0))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Int si = 0;
|
||||
Int pi = 0;
|
||||
for (;si < sit.len && pi < pit.len;) {
|
||||
while (si < sit.len && IsWhitespace(sit[si])) si += 1;
|
||||
while (pi < pit.len && IsWhitespace(pit[pi])) pi += 1;
|
||||
if (pi >= pit.len) break;
|
||||
if (si >= sit.len) break;
|
||||
|
||||
if (ToLowerCase(sit[si]) == ToLowerCase(pit[pi])) {
|
||||
matching += 1.0f;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
si += 1;
|
||||
pi += 1;
|
||||
}
|
||||
}
|
||||
score += matching;
|
||||
}
|
||||
points += consecutive * consecutive;
|
||||
return points;
|
||||
score = score / (float)s.len;
|
||||
return score;
|
||||
}
|
||||
|
||||
inline bool MergeSortCompare(FuzzyPair *a, FuzzyPair *b) {
|
||||
@@ -139,7 +161,7 @@ Array<FuzzyPair> FuzzySearchLines(Allocator allocator, Buffer *buffer, Int line_
|
||||
}
|
||||
s = Trim(s);
|
||||
|
||||
int32_t rating = FuzzyRate(s, needle);
|
||||
float rating = FuzzyRate(s, needle);
|
||||
Add(&ratings, {(int32_t)i, rating});
|
||||
}
|
||||
Array<FuzzyPair> temp = Copy(allocator, ratings);
|
||||
|
||||
Reference in New Issue
Block a user