Refactoring Add BSet
This commit is contained in:
@@ -81,28 +81,21 @@ void ToggleFullscreen() {
|
|||||||
IsInFullscreen = !IsInFullscreen;
|
IsInFullscreen = !IsInFullscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckpointBeforeGoto(WindowID window_id, ViewID view_id) {
|
void CheckpointBeforeGoto(Window *window, View *view) {
|
||||||
Window *window = GetWindow(window_id);
|
|
||||||
View *view = GetView(view_id);
|
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
Add(&window->goto_history, {buffer->id, view->carets[0]});
|
Add(&window->goto_history, {buffer->id, view->carets[0]});
|
||||||
window->goto_redo.len = 0;
|
window->goto_redo.len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckpointBeforeGoto(WindowID window_id) {
|
void CheckpointBeforeGoto(Window *window) {
|
||||||
Window *window = GetWindow(window_id);
|
CheckpointBeforeGoto(window, GetView(window->active_view));
|
||||||
CheckpointBeforeGoto(window_id, window->active_view);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GotoBackward(WindowID window_id) {
|
void GotoBackward(Window *window) {
|
||||||
Window *window = GetWindow(window_id);
|
BSet set = GetBSet(window);
|
||||||
if (window->goto_history.len <= 0) return;
|
if (window->goto_history.len <= 0) return;
|
||||||
{
|
Add(&window->goto_redo, {set.buffer->id, set.view->carets[0]});
|
||||||
Window *window = GetWindow(window_id);
|
|
||||||
View *view = GetView(window->active_view);
|
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
|
||||||
Add(&window->goto_redo, {buffer->id, view->carets[0]});
|
|
||||||
}
|
|
||||||
GotoCrumb c = Pop(&window->goto_history);
|
GotoCrumb c = Pop(&window->goto_history);
|
||||||
Buffer *buffer = GetBuffer(c.buffer_id);
|
Buffer *buffer = GetBuffer(c.buffer_id);
|
||||||
View *view = WindowOpenBufferView(window, buffer->name);
|
View *view = WindowOpenBufferView(window, buffer->name);
|
||||||
@@ -110,15 +103,11 @@ void GotoBackward(WindowID window_id) {
|
|||||||
UpdateScroll(window, true);
|
UpdateScroll(window, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GotoForward(WindowID window_id) {
|
void GotoForward(Window *window) {
|
||||||
Window *window = GetWindow(window_id);
|
BSet set = GetBSet(window);
|
||||||
if (window->goto_redo.len <= 0) return;
|
if (window->goto_redo.len <= 0) return;
|
||||||
{
|
Add(&window->goto_history, {set.buffer->id, set.view->carets[0]});
|
||||||
Window *window = GetWindow(window_id);
|
|
||||||
View *view = GetView(window->active_view);
|
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
|
||||||
Add(&window->goto_history, {buffer->id, view->carets[0]});
|
|
||||||
}
|
|
||||||
GotoCrumb c = Pop(&window->goto_redo);
|
GotoCrumb c = Pop(&window->goto_redo);
|
||||||
Buffer *buffer = GetBuffer(c.buffer_id);
|
Buffer *buffer = GetBuffer(c.buffer_id);
|
||||||
View *view = WindowOpenBufferView(window, buffer->name);
|
View *view = WindowOpenBufferView(window, buffer->name);
|
||||||
@@ -163,10 +152,8 @@ void MouseExecWord(Event event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Command_ListBuffers() {
|
void Command_ListBuffers() {
|
||||||
Window *window = GetActiveMainWindow();
|
BSet main = GetActiveMainSet();
|
||||||
View *view = GetView(window->active_view);
|
CheckpointBeforeGoto(main.window);
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
|
||||||
CheckpointBeforeGoto(window->id);
|
|
||||||
|
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
Array<String> strings = {scratch};
|
Array<String> strings = {scratch};
|
||||||
@@ -177,8 +164,8 @@ void Command_ListBuffers() {
|
|||||||
String result = Merge(scratch, strings, "\n");
|
String result = Merge(scratch, strings, "\n");
|
||||||
String16 string16 = ToString16(scratch, result);
|
String16 string16 = ToString16(scratch, result);
|
||||||
|
|
||||||
String buffer_name = GetUniqueBufferName(scratch, GetDir(buffer), "+list_buffers-");
|
String buffer_name = GetUniqueBufferName(scratch, GetDir(main.buffer), "+list_buffers-");
|
||||||
View *new_view = WindowOpenBufferView(window, buffer_name);
|
View *new_view = WindowOpenBufferView(main.window, buffer_name);
|
||||||
|
|
||||||
Command_SelectEntireBuffer(new_view);
|
Command_SelectEntireBuffer(new_view);
|
||||||
Command_Replace(new_view, string16);
|
Command_Replace(new_view, string16);
|
||||||
@@ -335,10 +322,10 @@ bool GlobalCommand(Event event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event.ctrl && event.shift && Mouse(RIGHT)) {
|
if (event.ctrl && event.shift && Mouse(RIGHT)) {
|
||||||
GotoForward(GetActiveMainWindowID());
|
GotoForward(GetActiveMainSet().window);
|
||||||
} else if (event.alt && event.ctrl && Mouse(RIGHT)) {
|
} else if (event.alt && event.ctrl && Mouse(RIGHT)) {
|
||||||
} else if (event.ctrl && Mouse(RIGHT)) {
|
} else if (event.ctrl && Mouse(RIGHT)) {
|
||||||
GotoBackward(GetActiveMainWindowID());
|
GotoBackward(GetActiveMainSet().window);
|
||||||
} else if (event.alt && Mouse(RIGHT)) {
|
} else if (event.alt && Mouse(RIGHT)) {
|
||||||
} else if (Mouse(RIGHT)) {
|
} else if (Mouse(RIGHT)) {
|
||||||
Vec2I mouse = MouseVec2I();
|
Vec2I mouse = MouseVec2I();
|
||||||
@@ -555,11 +542,8 @@ void ReportWarningf(const char *fmt, ...) {
|
|||||||
STRING_FORMAT(scratch, fmt, string);
|
STRING_FORMAT(scratch, fmt, string);
|
||||||
Command_Append(NullViewID, string, true);
|
Command_Append(NullViewID, string, true);
|
||||||
Window *window = GetWindowWithView(NullViewID);
|
Window *window = GetWindowWithView(NullViewID);
|
||||||
if (!window) {
|
if (!window) window = GetActiveMainSet().window;
|
||||||
WindowID last_active_window_id = GetActiveMainWindowID();
|
CheckpointBeforeGoto(window);
|
||||||
window = GetWindow(last_active_window_id);
|
|
||||||
}
|
|
||||||
CheckpointBeforeGoto(window->id);
|
|
||||||
window->active_view = NullViewID;
|
window->active_view = NullViewID;
|
||||||
ActiveWindow = window->id;
|
ActiveWindow = window->id;
|
||||||
}
|
}
|
||||||
@@ -619,7 +619,7 @@ void Command_Find(View *seek_view, String16 needle, bool forward = true) {
|
|||||||
|
|
||||||
void Command_GotoNextInList(Window *window, Int line_offset = 1) {
|
void Command_GotoNextInList(Window *window, Int line_offset = 1) {
|
||||||
Assert(line_offset == 1 || line_offset == -1);
|
Assert(line_offset == 1 || line_offset == -1);
|
||||||
ViewID active_view = window->active_view;
|
View *active_view = GetView(window->active_view);
|
||||||
|
|
||||||
View *view_goto = GetView(window->active_goto_list);
|
View *view_goto = GetView(window->active_goto_list);
|
||||||
window->active_view = view_goto->id;
|
window->active_view = view_goto->id;
|
||||||
@@ -639,13 +639,13 @@ void Command_GotoNextInList(Window *window, Int line_offset = 1) {
|
|||||||
IF_DEBUG(AssertRanges(view_goto->carets));
|
IF_DEBUG(AssertRanges(view_goto->carets));
|
||||||
if (line.len == 0) continue;
|
if (line.len == 0) continue;
|
||||||
|
|
||||||
CheckpointBeforeGoto(window->id, active_view);
|
CheckpointBeforeGoto(window, active_view);
|
||||||
Open(line);
|
Open(line);
|
||||||
opened = true;
|
opened = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!opened) window->active_view = active_view;
|
if (!opened) window->active_view = active_view->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Command_FuzzySort(View *view, String16 needle) {
|
void Command_FuzzySort(View *view, String16 needle) {
|
||||||
@@ -682,7 +682,7 @@ void WindowCommand(Event event, Window *window, View *view) {
|
|||||||
|
|
||||||
if (Press(SDLK_ESCAPE)) {
|
if (Press(SDLK_ESCAPE)) {
|
||||||
if (window->deactivate_on_escape) {
|
if (window->deactivate_on_escape) {
|
||||||
ActiveWindow = GetActiveMainWindowID();
|
ActiveWindow = GetActiveMainSet().window->id;
|
||||||
} else {
|
} else {
|
||||||
view->carets.len = 1;
|
view->carets.len = 1;
|
||||||
}
|
}
|
||||||
@@ -838,22 +838,18 @@ void WindowCommand(Event event, Window *window, View *view) {
|
|||||||
|
|
||||||
if (Shift(SDLK_F3)) {
|
if (Shift(SDLK_F3)) {
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
Window *window = GetActiveMainWindow();
|
BSet main = GetActiveMainSet();
|
||||||
View *view = GetView(window->active_view);
|
String16 search_string = ToString16(scratch, main.window->search_string);
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Caret caret = FindPrev(main.buffer, search_string, main.view->carets[0]);
|
||||||
String16 search_string = ToString16(scratch, window->search_string);
|
main.view->carets.len = 1;
|
||||||
Caret caret = FindPrev(buffer, search_string, view->carets[0]);
|
main.view->carets[0] = caret;
|
||||||
view->carets.len = 1;
|
|
||||||
view->carets[0] = caret;
|
|
||||||
} else if (Press(SDLK_F3)) {
|
} else if (Press(SDLK_F3)) {
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
Window *window = GetActiveMainWindow();
|
BSet main = GetActiveMainSet();
|
||||||
View *view = GetView(window->active_view);
|
String16 search_string = ToString16(scratch, main.window->search_string);
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Caret caret = FindNext(main.buffer, search_string, main.view->carets[0]);
|
||||||
String16 search_string = ToString16(scratch, window->search_string);
|
main.view->carets.len = 1;
|
||||||
Caret caret = FindNext(buffer, search_string, view->carets[0]);
|
main.view->carets[0] = caret;
|
||||||
view->carets.len = 1;
|
|
||||||
view->carets[0] = caret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Shift(SDLK_F4)) {
|
if (Shift(SDLK_F4)) {
|
||||||
@@ -878,11 +874,8 @@ void WindowCommand(Event event, Window *window, View *view) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Ctrl(SDLK_PERIOD)) {
|
if (Ctrl(SDLK_PERIOD)) {
|
||||||
Window *window = GetActiveMainWindow();
|
BSet main = GetActiveMainSet();
|
||||||
View *view = GetView(window->active_view);
|
String name = ChopLastSlash(main.buffer->name);
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
|
||||||
|
|
||||||
String name = ChopLastSlash(buffer->name);
|
|
||||||
Open(name);
|
Open(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -912,9 +905,9 @@ void WindowCommand(Event event, Window *window, View *view) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (CtrlShift(SDLK_W)) {
|
if (CtrlShift(SDLK_W)) {
|
||||||
GotoForward(GetActiveMainWindowID());
|
GotoForward(GetActiveMainSet().window);
|
||||||
} else if (Ctrl(SDLK_W)) {
|
} else if (Ctrl(SDLK_W)) {
|
||||||
GotoBackward(GetActiveMainWindowID());
|
GotoBackward(GetActiveMainSet().window);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CtrlShift(SDLK_Q)) {
|
if (CtrlShift(SDLK_Q)) {
|
||||||
|
|||||||
@@ -29,15 +29,18 @@ String FieldString(lua_State *L, String name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ExecInNewBuffer(String cmd, String working_dir) {
|
void ExecInNewBuffer(String cmd, String working_dir) {
|
||||||
|
BSet main = GetActiveMainSet();
|
||||||
|
CheckpointBeforeGoto(main.window);
|
||||||
|
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
CheckpointBeforeGoto(GetActiveMainWindowID());
|
|
||||||
String buffer_name = GetUniqueBufferName(scratch, working_dir, "+cmd-");
|
String buffer_name = GetUniqueBufferName(scratch, working_dir, "+cmd-");
|
||||||
Window *window = GetActiveMainWindow();
|
|
||||||
View *view = WindowOpenBufferView(window, buffer_name);
|
View *view = WindowOpenBufferView(main.window, buffer_name);
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
view->carets[0] = MakeCaret({});
|
|
||||||
|
view->carets[0] = MakeCaret({});
|
||||||
Exec(view->id, false, cmd, working_dir);
|
Exec(view->id, false, cmd, working_dir);
|
||||||
ActiveWindow = window->id;
|
ActiveWindow = main.window->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Open(String path) {
|
void Open(String path) {
|
||||||
@@ -59,17 +62,16 @@ void Open(String path) {
|
|||||||
String col_string = FieldString(LuaState, "col");
|
String col_string = FieldString(LuaState, "col");
|
||||||
Int col = strtoll(col_string.data, NULL, 10);
|
Int col = strtoll(col_string.data, NULL, 10);
|
||||||
|
|
||||||
WindowID window_id = GetActiveMainWindowID();
|
BSet main = GetActiveMainSet();
|
||||||
CheckpointBeforeGoto(window_id);
|
CheckpointBeforeGoto(main.window);
|
||||||
Window *window = GetWindow(window_id);
|
View *view = WindowOpenBufferView(main.window, file_path);
|
||||||
View *view = WindowOpenBufferView(window, file_path);
|
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
if (line != -1 && col != -1) {
|
if (line != -1 && col != -1) {
|
||||||
Int pos = XYToPos(*buffer, {col - 1, line - 1});
|
Int pos = XYToPos(*buffer, {col - 1, line - 1});
|
||||||
view->carets[0] = MakeCaret(pos);
|
view->carets[0] = MakeCaret(pos);
|
||||||
}
|
}
|
||||||
UpdateScroll(window, true);
|
UpdateScroll(main.window, true);
|
||||||
ActiveWindow = window->id;
|
ActiveWindow = main.window->id;
|
||||||
} else if (FieldString(LuaState, "kind") == "exec") {
|
} else if (FieldString(LuaState, "kind") == "exec") {
|
||||||
String cmd = FieldString(LuaState, "cmd");
|
String cmd = FieldString(LuaState, "cmd");
|
||||||
String working_dir = FieldString(LuaState, "working_dir");
|
String working_dir = FieldString(LuaState, "working_dir");
|
||||||
@@ -91,9 +93,8 @@ int Lua_FuzzySort(lua_State *L) {
|
|||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
String16 string16 = ToString16(scratch, string);
|
String16 string16 = ToString16(scratch, string);
|
||||||
|
|
||||||
Window *window = GetActiveMainWindow();
|
BSet main = GetActiveMainSet();
|
||||||
View *view = GetView(window->active_view);
|
Command_FuzzySort(main.view, string16);
|
||||||
Command_FuzzySort(view, string16);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,8 +116,8 @@ int Lua_NewCmd(lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Lua_Kill(lua_State *L) {
|
int Lua_Kill(lua_State *L) {
|
||||||
Window *window = GetActiveMainWindow();
|
BSet main = GetActiveMainSet();
|
||||||
KillProcess(window->active_view);
|
KillProcess(main.window->active_view);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,32 +182,37 @@ int Lua_GetActiveMainWindowBufferDir(lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Lua_OpenFilesHere(lua_State *L) {
|
int Lua_OpenFilesHere(lua_State *L) {
|
||||||
Window *window = GetActiveMainWindow();
|
BSet main = GetActiveMainSet();
|
||||||
|
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
for (FileIter it = IterateFiles(scratch, GetActiveMainWindowBufferDir()); IsValid(it); Advance(&it)) {
|
for (FileIter it = IterateFiles(scratch, GetActiveMainWindowBufferDir()); IsValid(it); Advance(&it)) {
|
||||||
WindowOpenBufferView(window, it.absolute_path);
|
WindowOpenBufferView(main.window, it.absolute_path);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Lua_Search(lua_State *L) {
|
int Lua_Search(lua_State *L) {
|
||||||
Window *seek_window = GetActiveMainWindow();
|
BSet main = GetActiveMainSet();
|
||||||
seek_window->search_string = lua_tostring(L, 1);
|
main.window->search_string = lua_tostring(L, 1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
View *seek_view = GetView(seek_window->active_view);
|
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
Command_Find(seek_view, ToString16(scratch, seek_window->search_string), true);
|
Command_Find(main.view, ToString16(scratch, main.window->search_string), true);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Lua_SearchB(lua_State *L) {
|
int Lua_SearchB(lua_State *L) {
|
||||||
Window *seek_window = GetActiveMainWindow();
|
BSet main = GetActiveMainSet();
|
||||||
seek_window->search_string = lua_tostring(L, 1);
|
main.window->search_string = lua_tostring(L, 1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
View *seek_view = GetView(seek_window->active_view);
|
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
Command_Find(seek_view, ToString16(scratch, seek_window->search_string), false);
|
Command_Find(main.view, ToString16(scratch, main.window->search_string), false);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Lua_Rename(lua_State *L) {
|
||||||
|
String string = lua_tostring(L, 1);
|
||||||
|
lua_pop(L, 1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,5 +14,6 @@ luaL_Reg LuaFunctions[] = {
|
|||||||
{"OpenFilesHere", Lua_OpenFilesHere},
|
{"OpenFilesHere", Lua_OpenFilesHere},
|
||||||
{"Search", Lua_Search},
|
{"Search", Lua_Search},
|
||||||
{"SearchB", Lua_SearchB},
|
{"SearchB", Lua_SearchB},
|
||||||
|
{"Rename", Lua_Rename},
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -77,8 +77,6 @@ inline View *GetView(ViewID id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline bool IsNull(Buffer *buffer) { return buffer->id.id == NullBufferID.id; }
|
inline bool IsNull(Buffer *buffer) { return buffer->id.id == NullBufferID.id; }
|
||||||
inline bool IsActive(Window *window) { return window->id.id == ActiveWindow.id; }
|
|
||||||
inline bool IsActive(Window *window, View *view) { return window->active_view.id == view->id.id; }
|
|
||||||
inline Window *GetActiveWindow() { return GetWindow(ActiveWindow); }
|
inline Window *GetActiveWindow() { return GetWindow(ActiveWindow); }
|
||||||
inline View *GetActiveView(Window *window) { return GetView(window->active_view); }
|
inline View *GetActiveView(Window *window) { return GetView(window->active_view); }
|
||||||
|
|
||||||
@@ -174,16 +172,35 @@ Window *GetTitlebarWindow(WindowID id) {
|
|||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
Window *GetActiveMainWindow() {
|
BSet GetBSet(Window *window) {
|
||||||
Window *window = GetWindow(ActiveWindow);
|
BSet set = {window};
|
||||||
if (window->is_title_bar) {
|
set.view = GetView(set.window->active_view);
|
||||||
window = GetWindow(window->title_bar_window);
|
set.buffer = GetBuffer(set.view->active_buffer);
|
||||||
}
|
return set;
|
||||||
return window;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowID GetActiveMainWindowID() {
|
BSet GetTitleSet(Window *window) {
|
||||||
return GetActiveMainWindow()->id;
|
if (!window->is_title_bar) window = GetWindow(window->title_bar_window);
|
||||||
|
BSet result = GetBSet(window);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
BSet GetMainSet(Window *window) {
|
||||||
|
if (window->is_title_bar) window = GetWindow(window->title_bar_window);
|
||||||
|
BSet result = GetBSet(window);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
BSet GetActiveMainSet() {
|
||||||
|
Window *window = GetWindow(ActiveWindow);
|
||||||
|
if (window->is_title_bar) window = GetWindow(window->title_bar_window);
|
||||||
|
return GetBSet(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
BSet GetActiveTitleSet() {
|
||||||
|
Window *window = GetWindow(ActiveWindow);
|
||||||
|
if (window->is_title_bar) window = GetWindow(window->title_bar_window);
|
||||||
|
return GetBSet(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
RandomSeed UniqueBufferNameSeed = {13};
|
RandomSeed UniqueBufferNameSeed = {13};
|
||||||
@@ -194,10 +211,8 @@ String GetUniqueBufferName(Allocator allocator, String working_dir, String p
|
|||||||
}
|
}
|
||||||
|
|
||||||
String GetActiveMainWindowBufferName() {
|
String GetActiveMainWindowBufferName() {
|
||||||
Window *window = GetActiveMainWindow();
|
BSet set = GetActiveMainSet();
|
||||||
View *view = GetView(window->active_view);
|
return set.buffer->name;
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
|
||||||
return buffer->name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String GetDir(Buffer *buffer) {
|
String GetDir(Buffer *buffer) {
|
||||||
@@ -206,10 +221,8 @@ String GetDir(Buffer *buffer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String GetActiveMainWindowBufferDir() {
|
String GetActiveMainWindowBufferDir() {
|
||||||
Window *window = GetActiveMainWindow();
|
BSet set = GetActiveMainSet();
|
||||||
View *view = GetView(window->active_view);
|
String name = set.buffer->is_directory ? set.buffer->name : ChopLastSlash(set.buffer->name);
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
|
||||||
String name = buffer->is_directory ? buffer->name : ChopLastSlash(buffer->name);
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ struct Scroller {
|
|||||||
Int line_count;
|
Int line_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ActiveSet {
|
struct BSet {
|
||||||
Window *window;
|
Window *window;
|
||||||
View *view;
|
View *view;
|
||||||
Buffer *buffer;
|
Buffer *buffer;
|
||||||
|
|||||||
@@ -1,29 +1,3 @@
|
|||||||
String DebugViewList(Allocator allocator) {
|
|
||||||
Scratch scratch((Arena *)allocator.object);
|
|
||||||
Array<String> strings = {scratch};
|
|
||||||
For(Views) {
|
|
||||||
View *view = it.o;
|
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
|
||||||
String string = Format(scratch, "view = %lld buffer = %lld name = %.*s", (long long)view->id.id, (long long)buffer->id.id, FmtString(buffer->name));
|
|
||||||
Add(&strings, string);
|
|
||||||
}
|
|
||||||
String result = Merge(allocator, strings, "\n");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
String DebugWindowList(Allocator allocator) {
|
|
||||||
Scratch scratch((Arena *)allocator.object);
|
|
||||||
Array<String> strings = {scratch};
|
|
||||||
For(Windows) {
|
|
||||||
View *view = GetActiveView(it.o);
|
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
|
||||||
String string = Format(scratch, "window = %lld active_view = %lld buffer_name = %.*s", (long long)it.id, (long long)view->id.id, FmtString(buffer->name));
|
|
||||||
Add(&strings, string);
|
|
||||||
}
|
|
||||||
String result = Merge(allocator, strings, "\n");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UpdateDebugBuffer() {
|
void UpdateDebugBuffer() {
|
||||||
Buffer *buffer = GetBuffer(DebugBufferID);
|
Buffer *buffer = GetBuffer(DebugBufferID);
|
||||||
|
|
||||||
@@ -31,12 +5,10 @@ void UpdateDebugBuffer() {
|
|||||||
View *view = GetActiveView(window);
|
View *view = GetActiveView(window);
|
||||||
if (view->active_buffer.id == buffer->id.id) return;
|
if (view->active_buffer.id == buffer->id.id) return;
|
||||||
|
|
||||||
Window *last_window = GetActiveMainWindow();
|
BSet main = GetActiveMainSet();
|
||||||
View *last_view = GetActiveView(last_window);
|
|
||||||
Buffer *last_buffer = GetBuffer(last_view->active_buffer);
|
|
||||||
|
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
String s = Format(scratch, "wid: %d\nvid: %d\nbid: %d\nframe: %lld\n", (int)last_window->id.id, (int)last_view->id.id, (int)last_buffer->id.id, (long long)FrameID);
|
String s = Format(scratch, "wid: %d\nvid: %d\nbid: %d\nframe: %lld\n", (int)main.window->id.id, (int)main.view->id.id, (int)main.buffer->id.id, (long long)FrameID);
|
||||||
String16 string = ToString16(scratch, s);
|
String16 string = ToString16(scratch, s);
|
||||||
IKnowWhatImDoing_ReplaceText(buffer, GetRange(*buffer), string);
|
IKnowWhatImDoing_ReplaceText(buffer, GetRange(*buffer), string);
|
||||||
|
|
||||||
@@ -48,13 +20,6 @@ void UpdateDebugBuffer() {
|
|||||||
IKnowWhatImDoing_Appendf(buffer, "working dir: %.*s\n", FmtString(WorkingDir));
|
IKnowWhatImDoing_Appendf(buffer, "working dir: %.*s\n", FmtString(WorkingDir));
|
||||||
IKnowWhatImDoing_Appendf(buffer, "exe dir: %.*s\n", FmtString(ExeDir));
|
IKnowWhatImDoing_Appendf(buffer, "exe dir: %.*s\n", FmtString(ExeDir));
|
||||||
IKnowWhatImDoing_Appendf(buffer, "config dir: %.*s\n", FmtString(ConfigDir));
|
IKnowWhatImDoing_Appendf(buffer, "config dir: %.*s\n", FmtString(ConfigDir));
|
||||||
|
|
||||||
// String view_list = DebugViewList(scratch);
|
|
||||||
// Append(buffer, ToString16(scratch, view_list));
|
|
||||||
// Append(buffer, L"\n");
|
|
||||||
|
|
||||||
// String window_list = DebugWindowList(scratch);
|
|
||||||
// Append(buffer, ToString16(scratch, window_list));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReplaceTitleBarData(Window *window) {
|
void ReplaceTitleBarData(Window *window) {
|
||||||
|
|||||||
@@ -109,7 +109,8 @@ void DrawWindow(Window *window, Event &event) {
|
|||||||
View *view = GetActiveView(window);
|
View *view = GetActiveView(window);
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
SetScissor(GetScreenRectF());
|
SetScissor(GetScreenRectF());
|
||||||
bool is_active = IsActive(window) || window->id.id == GetActiveMainWindowID().id;
|
|
||||||
|
bool is_active = window->id == ActiveWindow || window->title_bar_window == ActiveWindow;
|
||||||
|
|
||||||
Color color_whitespace_during_selection = ColorWhitespaceDuringSelection;
|
Color color_whitespace_during_selection = ColorWhitespaceDuringSelection;
|
||||||
Color color_background = ColorBackground;
|
Color color_background = ColorBackground;
|
||||||
|
|||||||
Reference in New Issue
Block a user