Files
tft/utils.hpp
T
2023-02-13 22:18:53 +02:00

49 lines
1.2 KiB
C++

#pragma once
#include <utility>
#include <ncursesw/ncurses.h>
#include "common/basicTypes.h"
/* template <class Vec> */
/* Vec& operator+=(Vec& lhs, Vec&& rhs) // Combine 2 vectors */
/* { */
/* lhs.reserve(lhs.size() + rhs.size()); */
/* for(auto&& el: rhs) */
/* lhs.push_back( std::move(el) ); */
/* return lhs; */
/* } */
/* template <class Vec> */
/* Vec& operator+=(Vec& lhs, const Vec& rhs) // Combine 2 vectors */
/* { */
/* lhs.reserve(lhs.size() + rhs.size()); */
/* for(const auto& el: rhs) */
/* lhs.push_back(el); */
/* return lhs; */
/* } */
template <class Vec>
void remove(Vec& vec, size_t pos) /* Remove from vector by moving the last element in its place */
{
vec[pos] = vec[vec.size() - 1];
vec.pop_back();
}
inline I32 min(I32 a, I32 b)
{
return a <= b ? a : b;
}
inline I32 max(I32 a, I32 b)
{
return a >= b ? a : b;
}
/* wheather a pad with the given coordinates will be visible */
bool willBeVisible(I16 drawY, I16 drawX, U16 height, U16 width);
/* like pnoutrefresh but pminrow,col are calculated based on width,height and
top left coords, which can be negative (outside the screen) */
void drawpad(WINDOW* pad, I16 drawY, I16 drawX);