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:
parent
96e8debf0b
commit
84dd0ce1ae
4 changed files with 72 additions and 59 deletions
23
Userland/Applications/HexEditor/Selection.h
Normal file
23
Userland/Applications/HexEditor/Selection.h
Normal 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)); }
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue