Compare commits
3 Commits
b140d9c3f1
...
5214ce61ac
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5214ce61ac | ||
|
|
ebf0f5de27 | ||
|
|
ca464c314b |
@@ -8,16 +8,13 @@ How to go about search/replace, opening code and other considerations
|
||||
- For fuzzy find number of files is the problem - most likely just getting them in one place is the biggest problem that can be optimized
|
||||
- Opening code is problematic for large / weird files, they stall for a while, getting them buffered up is hard. And they stall the execution when they go overboard. Maybe just skipping on filesisze on something would be enough, or making a very large skip list. Another solution would be lazy loaded buffers + determining what kind of file we are dealing with on open before loading
|
||||
- Search everything, like fuzzy panel, on every key stroke we grep immediately and get new results, cancel old, reset
|
||||
- ARENA CODE POSSIBLY DOMINATES
|
||||
|
||||
Use session 2
|
||||
- Need configs I can't change browser or vcvarsall currently, maybe syntax like :Set InternetBrowser "firefox"
|
||||
- BUILD annoying: Console or use the other window / the window which is already being used
|
||||
- Tutorial
|
||||
- When jumping should center the view!!!
|
||||
|
||||
Debug session:
|
||||
- Should highlight main buffer when clicking on status?
|
||||
- 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
|
||||
|
||||
@@ -1399,9 +1399,6 @@ void InitBuffers() {
|
||||
EventBuffer = CreateBuffer(sys_allocator, GetUniqueBufferName(WorkDir, "events"));
|
||||
EventBuffer->no_history = true;
|
||||
EventBuffer->special = true;
|
||||
BuildBuffer = CreateBuffer(sys_allocator, GetUniqueBufferName(WorkDir, "build"));
|
||||
BuildBuffer->no_history = true;
|
||||
BuildBuffer->special = true;
|
||||
}
|
||||
|
||||
Int ConvertUTF8ToUTF16UnixLine(String string, char16_t *buffer, Int buffer_cap) {
|
||||
|
||||
@@ -398,15 +398,14 @@ BSet Exec(String cmd, String working_dir, bool set_active = true) {
|
||||
}
|
||||
|
||||
BSet ExecBuild(String cmd) {
|
||||
BSet build = GetBSet(BuildWindowID);
|
||||
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||
NextActiveWindowID = main.window->id;
|
||||
View *view = WindowOpenBufferView(main.window, BuildBuffer->name);
|
||||
SelectRange(view, Range{});
|
||||
ResetBuffer(BuildBuffer);
|
||||
Exec(view->id, false, cmd, WorkDir); // NOTE: IN CASE WE MOVE THIS TO CONSOLE WINDOW, MAKE SURE TO SWITCH HERE the scrolling
|
||||
main.window->active_goto_list = view->id;
|
||||
SelectRange(build.view, Range{});
|
||||
ResetBuffer(build.buffer);
|
||||
Exec(build.view->id, true, cmd, WorkDir);
|
||||
main.window->active_goto_list = build.view->id;
|
||||
main.window->goto_list_pos = 0;
|
||||
return main;
|
||||
return build;
|
||||
}
|
||||
|
||||
void Command_SaveAll() {
|
||||
@@ -425,6 +424,8 @@ void Command_Build() {
|
||||
#else
|
||||
ExecBuild("sh build.sh");
|
||||
#endif
|
||||
BSet main = GetBSet(BuildWindowID);
|
||||
main.window->visible = true;
|
||||
} RegisterCommand(Command_Build, "f1");
|
||||
|
||||
void Command_GotoNextInList() {
|
||||
@@ -948,9 +949,6 @@ void Command_MakeFontSmaller() {
|
||||
|
||||
void Command_Open() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
if (active.window->id == CommandWindowID) {
|
||||
return;
|
||||
}
|
||||
Open(FetchLoadWord(active.view));
|
||||
} RegisterCommand(Command_Open, "ctrl-q");
|
||||
|
||||
@@ -1171,12 +1169,9 @@ void Command_InsertNewLineDown() {
|
||||
} RegisterCommand(Command_InsertNewLineDown, "ctrl-enter");
|
||||
|
||||
void Command_NewLine() {
|
||||
if (ActiveWindowID == CommandWindowID || ActiveWindowID == SearchWindowID) {
|
||||
return;
|
||||
}
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
IdentedNewLine(active.view);
|
||||
} RegisterCommand(Command_NewLine, "enter");
|
||||
} RegisterCommand(Command_NewLine, "enter | shift-enter");
|
||||
|
||||
void Command_CreateCaretOnNextFind() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
|
||||
@@ -27,12 +27,14 @@ WindowID NullWindowID;
|
||||
WindowID DebugWindowID;
|
||||
ViewID DebugViewID;
|
||||
BufferID DebugBufferID;
|
||||
|
||||
WindowID CommandWindowID;
|
||||
WindowID StatusBarWindowID;
|
||||
WindowID SearchWindowID;
|
||||
ViewID SearchViewID;
|
||||
BufferID SearchBufferID;
|
||||
WindowID BuildWindowID;
|
||||
ViewID BuildViewID;
|
||||
BufferID BuildBufferID;
|
||||
|
||||
WindowID NextActiveWindowID;
|
||||
WindowID ActiveWindowID;
|
||||
@@ -43,7 +45,6 @@ WindowID ResizerSelected = {-1};
|
||||
WindowID ResizerHover = {-1};
|
||||
Caret DocumentAnchor;
|
||||
|
||||
Buffer *BuildBuffer;
|
||||
Buffer *GCInfoBuffer;
|
||||
Buffer *EventBuffer;
|
||||
Buffer *TraceBuffer;
|
||||
@@ -162,5 +163,4 @@ RegisterVariable(String, ConfigFont, "/home/krz/text_editor/package/CascadiaMono
|
||||
RegisterVariable(String, ConfigVCVarsall, "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvars64.bat");
|
||||
RegisterVariable(Float, ConfigUndoMergeTimeWindow, 0.3);
|
||||
RegisterVariable(Float, ConfigJumpHistoryMergeTimeWindow, 0.3);
|
||||
RegisterVariable(Int, ConfigJumpHistorySize, 4096);
|
||||
RegisterVariable(String, ConfigInternetBrowser, "firefox");
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "window_debug.cpp"
|
||||
#include "window_status.cpp"
|
||||
#include "window_search.cpp"
|
||||
#include "window_build.cpp"
|
||||
|
||||
#include "process.cpp"
|
||||
#include "event.cpp"
|
||||
@@ -591,14 +592,6 @@ void Update(Event event) {
|
||||
}
|
||||
}
|
||||
it->skip_checkpoint = false;
|
||||
|
||||
|
||||
if (it->goto_history.len > ConfigJumpHistorySize) {
|
||||
RemoveByIndex(&it->goto_history, 0);
|
||||
}
|
||||
if (it->goto_redo.len > ConfigJumpHistorySize) {
|
||||
RemoveByIndex(&it->goto_redo, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (it->sync_visibility_with_focus) {
|
||||
@@ -617,6 +610,20 @@ void Update(Event event) {
|
||||
window = GetWindow(ActiveWindowID);
|
||||
}
|
||||
|
||||
// Behavior where these windows cannot be visible at the same time
|
||||
{
|
||||
WindowID id[] = {BuildWindowID, CommandWindowID, SearchWindowID};
|
||||
for (int i = 0; i < Lengthof(id); i += 1) {
|
||||
if (ActiveWindowID == id[i]) {
|
||||
for (int j = 0; j < Lengthof(id); j += 1) {
|
||||
if (i == j) continue;
|
||||
Window *window = GetWindow(id[j]);
|
||||
window->visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ActiveWindowID != LastActiveLayoutWindowID) {
|
||||
if (window->layout) {
|
||||
LastActiveLayoutWindowID = ActiveWindowID;
|
||||
|
||||
@@ -122,6 +122,7 @@ void InitWindows() {
|
||||
StatusWindowInit();
|
||||
DebugWindowInit();
|
||||
SearchWindowInit();
|
||||
BuildWindowInit();
|
||||
}
|
||||
|
||||
void CalcNiceties(Window *n) {
|
||||
@@ -148,10 +149,11 @@ void LayoutWindows(int16_t wx, int16_t wy) {
|
||||
ProfileFunction();
|
||||
Rect2I screen_rect = RectI0Size(wx, wy);
|
||||
|
||||
CommandWindowLayout(&screen_rect, wx, wy);
|
||||
StatusWindowLayout(&screen_rect, wx, wy);
|
||||
CommandWindowLayout(&screen_rect, wx, wy);
|
||||
DebugWindowLayout(&screen_rect, wx, wy);
|
||||
SearchWindowLayout(&screen_rect, wx, wy);
|
||||
BuildWindowLayout(&screen_rect, wx, wy);
|
||||
|
||||
// Column layout
|
||||
Int c = 0;
|
||||
|
||||
@@ -63,3 +63,6 @@ void StatusWindowLayout(Rect2I *rect, Int wx, Int wy);
|
||||
|
||||
void DebugWindowInit();
|
||||
void DebugWindowLayout(Rect2I *rect, Int wx, Int wy);
|
||||
|
||||
void BuildWindowInit();
|
||||
void BuildWindowLayout(Rect2I *rect, Int wx, Int wy);
|
||||
|
||||
38
src/text_editor/window_build.cpp
Normal file
38
src/text_editor/window_build.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
void BuildWindowInit() {
|
||||
Window *window = CreateWind();
|
||||
BuildWindowID = window->id;
|
||||
Buffer *buffer = CreateBuffer(SysAllocator, GetUniqueBufferName(WorkDir, "build"));
|
||||
buffer->special = true;
|
||||
buffer->no_history = true;
|
||||
BuildBufferID = buffer->id;
|
||||
View *view = CreateView(buffer->id);
|
||||
view->special = true;
|
||||
BuildViewID = view->id;
|
||||
window->active_view = view->id;
|
||||
window->draw_darker = true;
|
||||
window->draw_line_highlight = true;
|
||||
window->layout = false;
|
||||
window->visible = false;
|
||||
window->lose_visibility_on_escape = true;
|
||||
window->jump_history = false;
|
||||
}
|
||||
|
||||
void BuildWindowLayout(Rect2I *rect, Int wx, Int wy) {
|
||||
Window *n = GetWindow(BuildWindowID);
|
||||
Rect2I copy_rect = *rect;
|
||||
if (!n->visible) {
|
||||
rect = ©_rect;
|
||||
}
|
||||
Int barsize = n->font->line_spacing * 10;
|
||||
n->document_rect = n->total_rect = CutBottom(rect, barsize);
|
||||
}
|
||||
|
||||
void Command_ShowBuildWindow() {
|
||||
BSet main = GetBSet(BuildWindowID);
|
||||
if (ActiveWindowID != BuildWindowID) {
|
||||
main.window->visible = true;
|
||||
NextActiveWindowID = BuildWindowID;
|
||||
} else {
|
||||
main.window->visible = false;
|
||||
}
|
||||
} RegisterCommand(Command_ShowBuildWindow, "ctrl-grave");
|
||||
@@ -1,32 +1,3 @@
|
||||
void CommandWindowInit() {
|
||||
Window *window = CreateWind();
|
||||
CommandWindowID = window->id;
|
||||
Buffer *buffer = CreateBuffer(SysAllocator, GetUniqueBufferName(WorkDir, "command_bar"));
|
||||
buffer->special = true;
|
||||
View *view = CreateView(buffer->id);
|
||||
view->special = true;
|
||||
window->active_view = view->id;
|
||||
window->draw_line_numbers = false;
|
||||
window->draw_scrollbar = false;
|
||||
window->draw_darker = true;
|
||||
window->draw_line_highlight = true;
|
||||
window->layout = false;
|
||||
window->visible = false;
|
||||
window->sync_visibility_with_focus = true;
|
||||
window->lose_focus_on_escape = true;
|
||||
window->jump_history = false;
|
||||
}
|
||||
|
||||
void CommandWindowLayout(Rect2I *rect, Int wx, Int wy) {
|
||||
Window *n = GetWindow(CommandWindowID);
|
||||
Rect2I copy_rect = *rect;
|
||||
if (!n->visible) {
|
||||
rect = ©_rect;
|
||||
}
|
||||
Int barsize = Clamp((Int)n->font->line_spacing*10, (Int)0, (Int)wx - 100);
|
||||
n->document_rect = n->total_rect = CutBottom(rect, barsize);
|
||||
}
|
||||
|
||||
int32_t FuzzyRate(String16 string, String16 with) {
|
||||
ProfileFunction();
|
||||
if (with.len == 0) return 0;
|
||||
@@ -65,7 +36,6 @@ Array<FuzzyPair> FuzzySearchLines(Allocator allocator, Buffer *buffer, Int line_
|
||||
int32_t rating = FuzzyRate(s, needle);
|
||||
Add(&ratings, {(int32_t)i, rating});
|
||||
}
|
||||
|
||||
Array<FuzzyPair> temp = Copy(allocator, ratings);
|
||||
MergeSort(ratings.len, ratings.data, temp.data);
|
||||
return ratings;
|
||||
@@ -176,12 +146,39 @@ void OpenCommand(BSet active) {
|
||||
Open(string);
|
||||
}
|
||||
|
||||
void Command_OpenCommand() {
|
||||
if (ActiveWindowID != CommandWindowID) {
|
||||
return;
|
||||
}
|
||||
void Command_CommandWindowOpen() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||
NextActiveWindowID = main.window->id;
|
||||
OpenCommand(active);
|
||||
} RegisterCommand(Command_OpenCommand, "ctrl-q | enter");
|
||||
}
|
||||
|
||||
void CommandWindowLayout(Rect2I *rect, Int wx, Int wy) {
|
||||
Window *n = GetWindow(CommandWindowID);
|
||||
Rect2I copy_rect = *rect;
|
||||
if (!n->visible) {
|
||||
rect = ©_rect;
|
||||
}
|
||||
Int barsize = Clamp((Int)n->font->line_spacing*10, (Int)0, (Int)wx - 100);
|
||||
n->document_rect = n->total_rect = CutBottom(rect, barsize);
|
||||
}
|
||||
|
||||
void CommandWindowInit() {
|
||||
Window *window = CreateWind();
|
||||
CommandWindowID = window->id;
|
||||
Buffer *buffer = CreateBuffer(SysAllocator, GetUniqueBufferName(WorkDir, "command_bar"));
|
||||
buffer->special = true;
|
||||
View *view = CreateView(buffer->id);
|
||||
view->special = true;
|
||||
window->active_view = view->id;
|
||||
window->draw_line_numbers = false;
|
||||
window->draw_scrollbar = false;
|
||||
window->draw_darker = true;
|
||||
window->draw_line_highlight = true;
|
||||
window->layout = false;
|
||||
window->visible = false;
|
||||
window->sync_visibility_with_focus = true;
|
||||
window->lose_focus_on_escape = true;
|
||||
window->jump_history = false;
|
||||
AddHook(&view->hooks, "Open", "ctrl-q | enter", Command_CommandWindowOpen);
|
||||
}
|
||||
|
||||
@@ -1,38 +1,3 @@
|
||||
void SearchWindowInit() {
|
||||
Window *window = CreateWind();
|
||||
SearchWindowID = window->id;
|
||||
Buffer *buffer = CreateBuffer(SysAllocator, GetUniqueBufferName(WorkDir, "search"));
|
||||
buffer->special = true;
|
||||
SearchBufferID = buffer->id;
|
||||
View *view = CreateView(buffer->id);
|
||||
view->special = true;
|
||||
SearchViewID = view->id;
|
||||
window->active_view = view->id;
|
||||
window->draw_line_numbers = false;
|
||||
window->draw_scrollbar = false;
|
||||
window->draw_darker = true;
|
||||
window->draw_line_highlight = false;
|
||||
window->layout = false;
|
||||
window->visible = false;
|
||||
window->lose_visibility_on_escape = true;
|
||||
window->jump_history = false;
|
||||
}
|
||||
|
||||
void SearchWindowLayout(Rect2I *rect, Int wx, Int wy) {
|
||||
Window *command_window = GetWindow(CommandWindowID);
|
||||
if (command_window->visible) {
|
||||
return;
|
||||
}
|
||||
Window *n = GetWindow(SearchWindowID);
|
||||
Rect2I copy_rect = *rect;
|
||||
if (!n->visible) {
|
||||
rect = ©_rect;
|
||||
}
|
||||
Int barsize = GetExpandingBarSize(n);
|
||||
n->document_rect = n->total_rect = CutBottom(rect, barsize);
|
||||
n->line_numbers_rect = CutLeft(&n->document_rect, n->font->char_spacing * 6);
|
||||
}
|
||||
|
||||
void Command_Search() {
|
||||
BSet main = GetBSet(ActiveWindowID);
|
||||
String16 string = {};
|
||||
@@ -58,18 +23,12 @@ void SearchWindowFindNext(bool forward = true) {
|
||||
}
|
||||
|
||||
void Command_SearchNextInSearch() {
|
||||
if (ActiveWindowID != SearchWindowID) {
|
||||
return;
|
||||
}
|
||||
SearchWindowFindNext(true);
|
||||
} RegisterCommand(Command_SearchNextInSearch, "enter");
|
||||
}
|
||||
|
||||
void Command_SearchPrevInSearch() {
|
||||
if (ActiveWindowID != SearchWindowID) {
|
||||
return;
|
||||
}
|
||||
SearchWindowFindNext(false);
|
||||
} RegisterCommand(Command_SearchPrevInSearch, "shift-enter");
|
||||
}
|
||||
|
||||
void Command_SearchNext() {
|
||||
SearchWindowFindNext(true);
|
||||
@@ -100,15 +59,6 @@ void Command_SearchAll() {
|
||||
set.window->visible = false;
|
||||
} RegisterCommand(Command_SearchAll, "alt-f3");
|
||||
|
||||
void Command_SearchAllInSearch() {
|
||||
if (ActiveWindowID != SearchWindowID) {
|
||||
return;
|
||||
}
|
||||
SearchAll();
|
||||
BSet set = GetBSet(SearchWindowID);
|
||||
set.window->visible = false;
|
||||
} RegisterCommand(Command_SearchAllInSearch, "alt-enter");
|
||||
|
||||
void Command_ToggleCaseSensitiveSearch() {
|
||||
SearchCaseSensitive = !SearchCaseSensitive;
|
||||
} RegisterCommand(Command_ToggleCaseSensitiveSearch, "alt-c");
|
||||
@@ -127,3 +77,37 @@ void SearchWindowUpdate() {
|
||||
Find(main.view, seek, true);
|
||||
}
|
||||
}
|
||||
|
||||
void SearchWindowLayout(Rect2I *rect, Int wx, Int wy) {
|
||||
Window *n = GetWindow(SearchWindowID);
|
||||
Rect2I copy_rect = *rect;
|
||||
if (!n->visible) {
|
||||
rect = ©_rect;
|
||||
}
|
||||
Int barsize = GetExpandingBarSize(n);
|
||||
n->document_rect = n->total_rect = CutBottom(rect, barsize);
|
||||
n->line_numbers_rect = CutLeft(&n->document_rect, n->font->char_spacing * 6);
|
||||
}
|
||||
|
||||
void SearchWindowInit() {
|
||||
Window *window = CreateWind();
|
||||
SearchWindowID = window->id;
|
||||
Buffer *buffer = CreateBuffer(SysAllocator, GetUniqueBufferName(WorkDir, "search"));
|
||||
buffer->special = true;
|
||||
SearchBufferID = buffer->id;
|
||||
View *view = CreateView(buffer->id);
|
||||
view->special = true;
|
||||
SearchViewID = view->id;
|
||||
window->active_view = view->id;
|
||||
window->draw_line_numbers = false;
|
||||
window->draw_scrollbar = false;
|
||||
window->draw_darker = true;
|
||||
window->draw_line_highlight = false;
|
||||
window->layout = false;
|
||||
window->visible = false;
|
||||
window->lose_visibility_on_escape = true;
|
||||
window->jump_history = false;
|
||||
AddHook(&view->hooks, "SearchAll", "alt-enter", Command_SearchAll);
|
||||
AddHook(&view->hooks, "SearchPrevInSearch", "shift-enter", Command_SearchPrevInSearch);
|
||||
AddHook(&view->hooks, "SearchNextInSearch", "enter", Command_SearchNextInSearch);
|
||||
}
|
||||
|
||||
@@ -17,10 +17,6 @@ void StatusWindowInit() {
|
||||
}
|
||||
|
||||
void StatusWindowLayout(Rect2I *rect, Int wx, Int wy) {
|
||||
Window *command_window = GetWindow(CommandWindowID);
|
||||
if (command_window->visible) {
|
||||
return;
|
||||
}
|
||||
Window *n = GetWindow(StatusBarWindowID);
|
||||
Rect2I copy_rect = *rect;
|
||||
if (!n->visible) {
|
||||
@@ -33,10 +29,6 @@ void StatusWindowLayout(Rect2I *rect, Int wx, Int wy) {
|
||||
void StatusWindowUpdate() {
|
||||
ProfileFunction();
|
||||
Window *status_bar_window = GetWindow(StatusBarWindowID, NULL);
|
||||
if (status_bar_window == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
Scratch scratch;
|
||||
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||
BSet title = GetBSet(status_bar_window);
|
||||
|
||||
Reference in New Issue
Block a user