Add dirs to special buffers
This commit is contained in:
@@ -304,9 +304,7 @@ String GetWorkingDir(Allocator arena) {
|
||||
wchar_t wbuffer[1024];
|
||||
DWORD wsize = GetCurrentDirectoryW(Lengthof(wbuffer), wbuffer);
|
||||
Assert(wsize != 0);
|
||||
Assert(wsize < 1022);
|
||||
wbuffer[wsize++] = '/';
|
||||
wbuffer[wsize] = 0;
|
||||
wbuffer[wsize] = 0;
|
||||
|
||||
String path = ToString(arena, wbuffer, wsize);
|
||||
NormalizePathInPlace(path);
|
||||
|
||||
@@ -137,7 +137,7 @@ void _ApplyEdits(Buffer *buffer, Array<Edit> edits) {
|
||||
{
|
||||
Scratch scratch((Arena *)buffer->line_starts.allocator.object);
|
||||
Array<Edit> edits_copy = TightCopy(scratch, edits);
|
||||
MergeSort(edits.len, edits_copy.data, edits.data);
|
||||
if (edits.len > 1) MergeSort(edits.len, edits_copy.data, edits.data);
|
||||
edits = edits_copy;
|
||||
}
|
||||
|
||||
|
||||
@@ -459,7 +459,7 @@ View *FindView(BufferID buffer_id) {
|
||||
}
|
||||
|
||||
void AppendToConsole(String16 string) {
|
||||
Buffer *buffer = GetBuffer("*console*");
|
||||
Buffer *buffer = GetBuffer(ConsoleBufferID);
|
||||
|
||||
// @todo: ?
|
||||
View *view = FindView(buffer->id);
|
||||
|
||||
@@ -265,7 +265,7 @@ Array<Range> GetSelectedLinesSorted(Allocator allocator, View *view) {
|
||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||
Array<Caret> caret_copy = TightCopy(scratch, view->carets);
|
||||
Array<Caret> temp = TightCopy(scratch, view->carets);
|
||||
MergeSort(view->carets.len, caret_copy.data, temp.data);
|
||||
if (view->carets.len > 1) MergeSort(view->carets.len, caret_copy.data, temp.data);
|
||||
|
||||
Array<Range> result = {allocator};
|
||||
For(caret_copy) {
|
||||
@@ -487,7 +487,7 @@ void MergeCarets(View *view, Range *mouse_selection_anchor) {
|
||||
|
||||
Scratch scratch;
|
||||
Array<Caret> c1 = TightCopy(scratch, view->carets);
|
||||
MergeSort(view->carets.len, c1.data, view->carets.data);
|
||||
if (view->carets.len > 1) MergeSort(view->carets.len, c1.data, view->carets.data);
|
||||
view->carets.len = 0;
|
||||
|
||||
Int first_caret_index = 0;
|
||||
@@ -737,13 +737,13 @@ void WindowCommand(Event event, Window *window, View *view) {
|
||||
}
|
||||
|
||||
if (Ctrl(SDLK_F3)) {
|
||||
Buffer *search_buffer = GetBuffer("*search*");
|
||||
Buffer *search_buffer = GetBuffer(SearchBufferID);
|
||||
String16 search_string = GetString(*search_buffer);
|
||||
Caret caret = FindInBuffer(buffer, search_string, view->carets[0], true);
|
||||
Insert(&view->carets, caret, 0);
|
||||
MergeCarets(view);
|
||||
} else if (Press(SDLK_F3)) {
|
||||
Buffer *search_buffer = GetBuffer("*search*");
|
||||
Buffer *search_buffer = GetBuffer(SearchBufferID);
|
||||
String16 search_string = GetString(*search_buffer);
|
||||
Caret caret = FindInBuffer(buffer, search_string, view->carets[0], true);
|
||||
view->carets.len = 1;
|
||||
|
||||
@@ -16,6 +16,10 @@ WindowID PopupWindowID;
|
||||
WindowID DebugWindowID;
|
||||
WindowID ConsoleWindowID;
|
||||
|
||||
BufferID ConsoleBufferID;
|
||||
BufferID DebugBufferID;
|
||||
BufferID SearchBufferID;
|
||||
|
||||
// @note:
|
||||
// Remember that WindowCommand works on window handed it down from HandleEvent
|
||||
// just because we don't have NextActiveWindow doesn't mean that we work on new
|
||||
|
||||
@@ -24,7 +24,7 @@ String DebugWindowList(Allocator allocator) {
|
||||
}
|
||||
|
||||
void ReplaceDebugData() {
|
||||
Buffer *buffer = GetBuffer("*debug*");
|
||||
Buffer *buffer = GetBuffer(DebugBufferID);
|
||||
|
||||
Window *window = GetActiveWindow();
|
||||
View *view = GetActiveView(window);
|
||||
@@ -44,6 +44,9 @@ void ReplaceDebugData() {
|
||||
Appendf(buffer, "mouse: [%f, %f]\n", xmouse, ymouse);
|
||||
Appendf(buffer, "window count: %d view count: %d buffer count: %d\n", (int)Windows.len, (int)Views.len, (int)Buffers.len);
|
||||
Appendf(buffer, "C:/Work/text_editor/src/text_editor/text_editor.cpp\n");
|
||||
Appendf(buffer, "working dir: %.*s\n", FmtString(WorkingDir));
|
||||
Appendf(buffer, "exe dir: %.*s\n", FmtString(ExeDir));
|
||||
Appendf(buffer, "config dir: %.*s\n", FmtString(ConfigDir));
|
||||
|
||||
// String view_list = DebugViewList(scratch);
|
||||
// Append(buffer, ToString16(scratch, view_list));
|
||||
|
||||
@@ -109,9 +109,14 @@ bool ToggleVisibility(Window *window) {
|
||||
return visible;
|
||||
}
|
||||
|
||||
String BuffCWD(String string) {
|
||||
String result = Format(Perm, "%.*s/%.*s", FmtString(WorkingDir), FmtString(string));
|
||||
return result;
|
||||
}
|
||||
|
||||
void InitScratchBuffer() {
|
||||
Allocator sys_allocator = GetSystemAllocator();
|
||||
Buffer *null_buffer = CreateBuffer(sys_allocator, "*scratch*");
|
||||
Buffer *null_buffer = CreateBuffer(sys_allocator, BuffCWD("*scratch*"));
|
||||
View *null_view = CreateView(null_buffer->id);
|
||||
}
|
||||
|
||||
@@ -122,7 +127,7 @@ void InitWindows() {
|
||||
Window *window = CreateWindow();
|
||||
window->is_column = true;
|
||||
// window->draw_line_numbers = false;
|
||||
Buffer *buffer = CreateBuffer(sys_allocator, "*load_text_a*");
|
||||
Buffer *buffer = CreateBuffer(sys_allocator, BuffCWD("*load_text_a*"));
|
||||
View *view = CreateView(buffer->id);
|
||||
// LoadTextA(buffer);
|
||||
LoadUnicode(buffer);
|
||||
@@ -136,7 +141,7 @@ void InitWindows() {
|
||||
window->absolute_position = true;
|
||||
window->dont_save_in_active_window_history = true;
|
||||
|
||||
Buffer *buffer = CreateBuffer(sys_allocator, "*console*");
|
||||
Buffer *buffer = CreateBuffer(sys_allocator, BuffCWD("*console*"));
|
||||
// buffer->no_history = true;
|
||||
View *view = CreateView(buffer->id);
|
||||
window->active_view = view->id;
|
||||
@@ -145,12 +150,13 @@ void InitWindows() {
|
||||
SetVisibility(window, false);
|
||||
|
||||
ConsoleWindowID = window->id;
|
||||
ConsoleBufferID = buffer->id;
|
||||
}
|
||||
|
||||
{
|
||||
Window *window = CreateWindow();
|
||||
window->draw_line_numbers = false;
|
||||
Buffer *buffer = CreateBuffer(sys_allocator, "*debug*");
|
||||
Buffer *buffer = CreateBuffer(sys_allocator, BuffCWD("*debug*"));
|
||||
window->absolute_position = true;
|
||||
window->draw_line_numbers = false;
|
||||
window->draw_scrollbar = false;
|
||||
@@ -164,6 +170,7 @@ void InitWindows() {
|
||||
titlebar->z = 2;
|
||||
SetVisibility(window, false);
|
||||
DebugWindowID = window->id;
|
||||
DebugBufferID = buffer->id;
|
||||
}
|
||||
|
||||
{
|
||||
@@ -175,7 +182,7 @@ void InitWindows() {
|
||||
w->absolute_position = true;
|
||||
w->dont_save_in_active_window_history = true;
|
||||
w->deactivate_on_escape = true;
|
||||
Buffer *b = CreateBuffer(sys_allocator, "*commands*");
|
||||
Buffer *b = CreateBuffer(sys_allocator, BuffCWD("*commands*"));
|
||||
View *v = CreateView(b->id);
|
||||
v->fuzzy_search = true;
|
||||
|
||||
@@ -198,13 +205,14 @@ void InitWindows() {
|
||||
w->dont_save_in_active_window_history = true;
|
||||
w->invisible_when_inactive = true;
|
||||
w->deactivate_on_escape = true;
|
||||
Buffer *b = CreateBuffer(sys_allocator, "*search*");
|
||||
Buffer *b = CreateBuffer(sys_allocator, BuffCWD("*search*"));
|
||||
View *v = CreateView(b->id);
|
||||
w->active_view = v->id;
|
||||
|
||||
CreateTitlebar(w);
|
||||
SetVisibility(w, false);
|
||||
|
||||
SearchBufferID = b->id;
|
||||
SearchWindowID = w->id;
|
||||
}
|
||||
|
||||
@@ -218,7 +226,7 @@ void InitWindows() {
|
||||
w->absolute_position = true;
|
||||
w->deactivate_on_escape = true;
|
||||
w->z = 2;
|
||||
Buffer *b = CreateBuffer(sys_allocator, "*popup*");
|
||||
Buffer *b = CreateBuffer(sys_allocator, BuffCWD("*popup*"));
|
||||
b->no_history = true;
|
||||
View *v = CreateView(b->id);
|
||||
w->active_view = v->id;
|
||||
|
||||
Reference in New Issue
Block a user