Remove dependence on FrameID
This commit is contained in:
@@ -170,7 +170,6 @@ void ReplaceText(Buffer *buffer, Range range, String16 string) {
|
|||||||
Assert(range.min >= 0 && range.min <= buffer->len);
|
Assert(range.min >= 0 && range.min <= buffer->len);
|
||||||
buffer->dirty = true;
|
buffer->dirty = true;
|
||||||
buffer->change_id += 1;
|
buffer->change_id += 1;
|
||||||
buffer->change_frame_id = FrameID;
|
|
||||||
|
|
||||||
Int size_to_remove = range.max - range.min;
|
Int size_to_remove = range.max - range.min;
|
||||||
Int size_to_add = string.len;
|
Int size_to_add = string.len;
|
||||||
|
|||||||
@@ -303,20 +303,20 @@ void ApplyTitleBarChangesToWindow(Window *window, View *view, Buffer *buffer) {
|
|||||||
Window *last_window = GetWindow(window->title_bar_window);
|
Window *last_window = GetWindow(window->title_bar_window);
|
||||||
View *last_view = GetActiveView(last_window);
|
View *last_view = GetActiveView(last_window);
|
||||||
Buffer *last_buffer = GetBuffer(last_view->active_buffer);
|
Buffer *last_buffer = GetBuffer(last_view->active_buffer);
|
||||||
|
Scratch scratch;
|
||||||
|
|
||||||
// @todo: maybe intern the filenames?
|
String filepath = ToString(scratch, buffer_string);
|
||||||
// @leak
|
if (filepath != last_buffer->name && !BufferNameExists(filepath)) {
|
||||||
String filepath = ToString(Perm, buffer_string);
|
// @todo: maybe intern the filenames?
|
||||||
if (!BufferNameExists(filepath)) {
|
// @leak
|
||||||
last_buffer->name = filepath;
|
last_buffer->name = Copy(Perm, filepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
Scratch scratch;
|
String line_string = ToString(scratch, line);
|
||||||
String line_string = ToString(scratch, line);
|
String col_string = ToString(scratch, col);
|
||||||
String col_string = ToString(scratch, col);
|
Int linei = strtoll(line_string.data, NULL, 10) - 1;
|
||||||
Int linei = strtoll(line_string.data, NULL, 10) - 1;
|
Int coli = strtoll(col_string.data, NULL, 10) - 1;
|
||||||
Int coli = strtoll(col_string.data, NULL, 10) - 1;
|
Int buffer_pos = XYToPos(*last_buffer, {coli, linei});
|
||||||
Int buffer_pos = XYToPos(*last_buffer, {coli, linei});
|
|
||||||
|
|
||||||
Caret &caret = last_view->carets[0];
|
Caret &caret = last_view->carets[0];
|
||||||
if (GetFront(caret) != buffer_pos) {
|
if (GetFront(caret) != buffer_pos) {
|
||||||
@@ -329,9 +329,7 @@ void ReplaceTitleBarData(Window *window) {
|
|||||||
view->scroll.y = 0;
|
view->scroll.y = 0;
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
if (IsActive(window)) {
|
if (IsActive(window)) {
|
||||||
if (buffer->change_frame_id == FrameID) {
|
ApplyTitleBarChangesToWindow(window, view, buffer);
|
||||||
ApplyTitleBarChangesToWindow(window, view, buffer);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ WindowID DebugWindowID;
|
|||||||
Array<WindowID> WindowSwitchHistory; // @todo: probably better as a circular buffer
|
Array<WindowID> WindowSwitchHistory; // @todo: probably better as a circular buffer
|
||||||
WindowID ActiveWindow;
|
WindowID ActiveWindow;
|
||||||
Int CaretChangeID;
|
Int CaretChangeID;
|
||||||
Int LastFrameIDWhenSwitchedActiveWindow;
|
|
||||||
|
|
||||||
inline ViewID AllocViewID() { return {ViewIDs.id++}; }
|
inline ViewID AllocViewID() { return {ViewIDs.id++}; }
|
||||||
inline WindowID AllocWindowID() { return {WindowIDs.id++}; }
|
inline WindowID AllocWindowID() { return {WindowIDs.id++}; }
|
||||||
@@ -100,17 +99,12 @@ WindowID GetLastActiveWindow() {
|
|||||||
return NullWindowID;
|
return NullWindowID;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetActiveWindow(WindowID window) {
|
void SetActiveWindow(WindowID window) {
|
||||||
if (window.id != ActiveWindow.id && LastFrameIDWhenSwitchedActiveWindow != FrameID) {
|
ActiveWindow = window;
|
||||||
LastFrameIDWhenSwitchedActiveWindow = FrameID;
|
Window *w = GetWindow(window);
|
||||||
ActiveWindow = window;
|
if (!w->dont_save_in_active_window_history) {
|
||||||
Window *w = GetWindow(window);
|
Add(&WindowSwitchHistory, window);
|
||||||
if (!w->dont_save_in_active_window_history) {
|
|
||||||
Add(&WindowSwitchHistory, window);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetActiveView(Window *window, ViewID view_id) {
|
void SetActiveView(Window *window, ViewID view_id) {
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ struct Buffer {
|
|||||||
BufferID id;
|
BufferID id;
|
||||||
String name;
|
String name;
|
||||||
Int change_id;
|
Int change_id;
|
||||||
Int change_frame_id;
|
|
||||||
|
|
||||||
union {
|
union {
|
||||||
U16 *data;
|
U16 *data;
|
||||||
@@ -59,6 +58,7 @@ struct Window {
|
|||||||
CircularArray<ViewID> view_history;
|
CircularArray<ViewID> view_history;
|
||||||
|
|
||||||
WindowID title_bar_window;
|
WindowID title_bar_window;
|
||||||
|
Int title_bar_last_buffer_change_id;
|
||||||
|
|
||||||
Rect2I total_rect;
|
Rect2I total_rect;
|
||||||
Rect2I scrollbar_rect;
|
Rect2I scrollbar_rect;
|
||||||
@@ -103,7 +103,12 @@ struct Scroller {
|
|||||||
Int line_count;
|
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 WorkingDir;
|
||||||
String ConfigDir;
|
String ConfigDir;
|
||||||
String ExeDir;
|
String ExeDir;
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
- bugs:
|
- bugs:
|
||||||
- scrolling when clicking on scroller is busted
|
- 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
|
- Windows
|
||||||
- Mark windows as absolute or non-automatic layout and then just loop through windows
|
- Mark windows as absolute or non-automatic layout and then just loop through windows
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ void InitWindows(View *null_view) {
|
|||||||
Buffer *buffer = CreateBuffer(sys_allocator, "*load_text_a*");
|
Buffer *buffer = CreateBuffer(sys_allocator, "*load_text_a*");
|
||||||
View *view = CreateView(buffer->id);
|
View *view = CreateView(buffer->id);
|
||||||
// LoadTextA(buffer);
|
// LoadTextA(buffer);
|
||||||
// LoadUnicode(buffer);
|
LoadUnicode(buffer);
|
||||||
LoadBigTextAndBigLine(buffer, 10000000);
|
// LoadBigTextAndBigLine(buffer, 10000000);
|
||||||
window->active_view = view->id;
|
window->active_view = view->id;
|
||||||
SetActiveView(window, view->id);
|
SetActiveView(window, view->id);
|
||||||
CreateInfobar(window);
|
CreateInfobar(window);
|
||||||
|
|||||||
Reference in New Issue
Block a user