diff options
author | kdx <kikoodx@paranoici.org> | 2023-01-15 03:16:15 +0100 |
---|---|---|
committer | kdx <kikoodx@paranoici.org> | 2023-01-15 03:16:30 +0100 |
commit | d519ce684ece884475adf00f67353013c299a74f (patch) | |
tree | 75c75c73871fe01424be6cd25ae1e08ede7f2121 | |
parent | 23a972f9ef5c3f926702be93d7cbb2369870c40d (diff) | |
download | 005-d519ce684ece884475adf00f67353013c299a74f.tar.gz |
clippin
-rw-r--r-- | Table.cpp | 7 | ||||
-rw-r--r-- | util.cpp | 4 | ||||
-rw-r--r-- | util.hpp | 6 |
3 files changed, 13 insertions, 4 deletions
@@ -1,13 +1,12 @@ #include "Table.hpp" #include "Cursor.hpp" #include "cfg.hpp" +#include "util.hpp" #include "lzr.h" #include <stdlib.h> -Table::Table() : _notes(), _edited(-1) +Table::Table() : _notes(), _strength(), _edited(-1) { - for (int i = 0; i < _width; i++) - _strength[i] = 1; } void Table::update(const Cursor& cursor) @@ -23,7 +22,7 @@ void Table::update(const Cursor& cursor) _strength[x] += 1; else _strength[x] = 1; - _notes[x] = cursor.y; + _notes[x] = util::min(CFG_DHEIGHT - 1, util::max(0, cursor.y)); _edited = x; } else if (cursor.erase) { _strength[x] = 0; diff --git a/util.cpp b/util.cpp new file mode 100644 index 0000000..2abdef3 --- /dev/null +++ b/util.cpp @@ -0,0 +1,4 @@ +#include "util.hpp" + +int util::min(int a, int b) { return (a < b) ? a : b; } +int util::max(int a, int b) { return (a > b) ? a : b; } diff --git a/util.hpp b/util.hpp new file mode 100644 index 0000000..6835f8f --- /dev/null +++ b/util.hpp @@ -0,0 +1,6 @@ +#pragma once + +namespace util { + int min(int a, int b); + int max(int a, int b); +} |