1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 19:37:34 +00:00

HexEditor: Wrap selection and behavior in a struct

This commit is contained in:
Sam Atkins 2024-01-09 20:19:45 +00:00 committed by Sam Atkins
parent 96e8debf0b
commit 84dd0ce1ae
4 changed files with 72 additions and 59 deletions

View file

@ -0,0 +1,23 @@
/*
* Copyright (c) 2024, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Types.h>
struct Selection {
size_t start { 0 };
size_t end { 0 };
void clear()
{
start = 0;
end = 0;
}
bool is_empty() const { return start == end; }
size_t size() const { return (start < end) ? (end - start) : (start - end); }
bool contains(size_t position) const { return (min(start, end) <= position) && (position < max(start, end)); }
};