Remove dependence on FrameID

This commit is contained in:
Krzosa Karol
2024-08-01 16:44:58 +02:00
parent 6ce5fd59a3
commit d6378922cf
6 changed files with 31 additions and 31 deletions

View File

@@ -170,7 +170,6 @@ void ReplaceText(Buffer *buffer, Range range, String16 string) {
Assert(range.min >= 0 && range.min <= buffer->len);
buffer->dirty = true;
buffer->change_id += 1;
buffer->change_frame_id = FrameID;
Int size_to_remove = range.max - range.min;
Int size_to_add = string.len;

View File

@@ -303,20 +303,20 @@ void ApplyTitleBarChangesToWindow(Window *window, View *view, Buffer *buffer) {
Window *last_window = GetWindow(window->title_bar_window);
View *last_view = GetActiveView(last_window);
Buffer *last_buffer = GetBuffer(last_view->active_buffer);
Scratch scratch;
// @todo: maybe intern the filenames?
// @leak
String filepath = ToString(Perm, buffer_string);
if (!BufferNameExists(filepath)) {
last_buffer->name = filepath;
String filepath = ToString(scratch, buffer_string);
if (filepath != last_buffer->name && !BufferNameExists(filepath)) {
// @todo: maybe intern the filenames?
// @leak
last_buffer->name = Copy(Perm, filepath);
}
Scratch scratch;
String line_string = ToString(scratch, line);
String col_string = ToString(scratch, col);
Int linei = strtoll(line_string.data, NULL, 10) - 1;
Int coli = strtoll(col_string.data, NULL, 10) - 1;
Int buffer_pos = XYToPos(*last_buffer, {coli, linei});
String line_string = ToString(scratch, line);
String col_string = ToString(scratch, col);
Int linei = strtoll(line_string.data, NULL, 10) - 1;
Int coli = strtoll(col_string.data, NULL, 10) - 1;
Int buffer_pos = XYToPos(*last_buffer, {coli, linei});
Caret &caret = last_view->carets[0];
if (GetFront(caret) != buffer_pos) {
@@ -329,9 +329,7 @@ void ReplaceTitleBarData(Window *window) {
view->scroll.y = 0;
Buffer *buffer = GetBuffer(view->active_buffer);
if (IsActive(window)) {
if (buffer->change_frame_id == FrameID) {
ApplyTitleBarChangesToWindow(window, view, buffer);
}
ApplyTitleBarChangesToWindow(window, view, buffer);
return;
}

View File

@@ -18,7 +18,6 @@ WindowID DebugWindowID;
Array<WindowID> WindowSwitchHistory; // @todo: probably better as a circular buffer
WindowID ActiveWindow;
Int CaretChangeID;
Int LastFrameIDWhenSwitchedActiveWindow;
inline ViewID AllocViewID() { return {ViewIDs.id++}; }
inline WindowID AllocWindowID() { return {WindowIDs.id++}; }
@@ -100,17 +99,12 @@ WindowID GetLastActiveWindow() {
return NullWindowID;
}
bool SetActiveWindow(WindowID window) {
if (window.id != ActiveWindow.id && LastFrameIDWhenSwitchedActiveWindow != FrameID) {
LastFrameIDWhenSwitchedActiveWindow = FrameID;
ActiveWindow = window;
Window *w = GetWindow(window);
if (!w->dont_save_in_active_window_history) {
Add(&WindowSwitchHistory, window);
}
return true;
void SetActiveWindow(WindowID window) {
ActiveWindow = window;
Window *w = GetWindow(window);
if (!w->dont_save_in_active_window_history) {
Add(&WindowSwitchHistory, window);
}
return false;
}
void SetActiveView(Window *window, ViewID view_id) {

View File

@@ -24,7 +24,6 @@ struct Buffer {
BufferID id;
String name;
Int change_id;
Int change_frame_id;
union {
U16 *data;
@@ -59,6 +58,7 @@ struct Window {
CircularArray<ViewID> view_history;
WindowID title_bar_window;
Int title_bar_last_buffer_change_id;
Rect2I total_rect;
Rect2I scrollbar_rect;
@@ -103,7 +103,12 @@ struct Scroller {
Int line_count;
};
Int FrameID;
// @WARNING: be careful about using this, should only be used for debugging
// the problem with this is that we want events to be reproducible.
// We eat as many events as we can in a frame, we abstract the frame and so on.
// Dont use it
Int FrameID;
String WorkingDir;
String ConfigDir;
String ExeDir;

View File

@@ -1,6 +1,10 @@
- bugs:
- scrolling when clicking on scroller is busted
- rewrite the main loop to make sure all of code runs for frame
- simulation:
- make the editor replayable, store events and then replay
- be careful about globals
- Windows
- Mark windows as absolute or non-automatic layout and then just loop through windows

View File

@@ -48,8 +48,8 @@ void InitWindows(View *null_view) {
Buffer *buffer = CreateBuffer(sys_allocator, "*load_text_a*");
View *view = CreateView(buffer->id);
// LoadTextA(buffer);
// LoadUnicode(buffer);
LoadBigTextAndBigLine(buffer, 10000000);
LoadUnicode(buffer);
// LoadBigTextAndBigLine(buffer, 10000000);
window->active_view = view->id;
SetActiveView(window, view->id);
CreateInfobar(window);