Equality operators for ids
This commit is contained in:
@@ -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 ⁢
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user