diff --git a/src/text_editor/commands.cpp b/src/text_editor/commands.cpp index 820df25..dae2aa0 100644 --- a/src/text_editor/commands.cpp +++ b/src/text_editor/commands.cpp @@ -202,7 +202,7 @@ bool GlobalCommand(Event event) { run_window_command = false; } - if (DocumentSelected.id != ActiveWindow.id) { + if (DocumentSelected != ActiveWindow) { DocumentSelected.id = -1; } else if (IsDocumentSelectionValid() && MouseUp()) { Assert(ScrollbarSelected.id == -1); @@ -451,7 +451,7 @@ bool GlobalCommand(Event event) { View *FindView(BufferID buffer_id) { For(Views) { - if (it.active_buffer.id == buffer_id.id) { + if (it.active_buffer == buffer_id) { return ⁢ } } diff --git a/src/text_editor/commands_window.cpp b/src/text_editor/commands_window.cpp index 72d2e80..80e02e8 100644 --- a/src/text_editor/commands_window.cpp +++ b/src/text_editor/commands_window.cpp @@ -761,7 +761,7 @@ void WindowCommand(Event event, Window *window, View *view) { view->carets[0] = caret; } - if (window->id.id == SearchWindowID.id) { + if (window->id == SearchWindowID) { Window *seek_window = GetWindow(GetLastActiveWindow()); View *seek_view = GetView(seek_window->active_view); Buffer *seek_buffer = GetBuffer(seek_view->active_buffer); @@ -820,7 +820,7 @@ void WindowCommand(Event event, Window *window, View *view) { Command_SelectRangeOneCursor(view, GetLineRangeWithoutNL(*buffer, 0)); Command_Replace(view, {}); } - } else if (window->id.id == SearchWindowID.id) { + } else if (window->id == SearchWindowID) { } else { if (CtrlShift(SDLK_RETURN)) { Command_MoveCursorsToSide(view, DIR_LEFT); diff --git a/src/text_editor/management.cpp b/src/text_editor/management.cpp index adee5ce..aa7b697 100644 --- a/src/text_editor/management.cpp +++ b/src/text_editor/management.cpp @@ -72,6 +72,13 @@ inline View *GetView(ViewID id) { return &Views[0]; } +inline bool operator==(WindowID a, WindowID b) { return a.id == b.id; } +inline bool operator==(BufferID a, BufferID b) { return a.id == b.id; } +inline bool operator==(ViewID a, ViewID b) { return a.id == b.id; } +inline bool operator!=(WindowID a, WindowID b) { return a.id != b.id; } +inline bool operator!=(BufferID a, BufferID b) { return a.id != b.id; } +inline bool operator!=(ViewID a, ViewID b) { return a.id != b.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; } diff --git a/src/text_editor/text_editor.cpp b/src/text_editor/text_editor.cpp index 641ce9a..a9fdc19 100644 --- a/src/text_editor/text_editor.cpp +++ b/src/text_editor/text_editor.cpp @@ -173,7 +173,7 @@ void Update(Event event) { Window *window = &Windows[it]; { if (window->invisible_when_inactive) { - bool title_bar_is_active = ActiveWindow.id == window->title_bar_window.id; + bool title_bar_is_active = ActiveWindow == window->title_bar_window; bool is_active = IsActive(window); if (is_active || title_bar_is_active) { SetVisibility(window, true);