dius
0.1.0
Loading...
Searching...
No Matches
tty.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "di/reflect/prelude.h"
4
#include "di/types/integers.h"
5
6
namespace
dius::tty
{
7
struct
WindowSize
{
8
u32
rows
{ 0 };
9
u32
cols
{ 0 };
10
u32
pixel_width
{ 0 };
11
u32
pixel_height
{ 0 };
12
13
auto
rows_shrinked
(u32 r) ->
WindowSize
{
14
if
(r >=
rows
) {
15
return
{ 0,
cols
,
pixel_width
, 0 };
16
}
17
return
{
rows
- r,
cols
,
pixel_width
,
pixel_height
- (r *
pixel_height
/
rows
) };
18
}
19
20
auto
cols_shrinked
(u32 c) ->
WindowSize
{
21
if
(c >=
cols
) {
22
return
{
rows
, 0, 0,
pixel_height
};
23
}
24
return
{
rows
,
cols
- c,
pixel_width
- (c *
pixel_width
/
cols
),
pixel_height
};
25
}
26
27
auto
operator==
(
WindowSize
const
&)
const
->
bool
=
default
;
28
29
constexpr
friend
auto
tag_invoke
(di::Tag<di::reflect>, di::InPlaceType<WindowSize>) {
30
return
di::make_fields<
"WindowSize"
>(di::field<
"rows"
, &
WindowSize::rows
>, di::field<
"cols"
, &
WindowSize::cols
>,
31
di::field<
"pixel_width"
, &
WindowSize::pixel_width
>,
32
di::field<
"pixel_height"
, &
WindowSize::pixel_height
>);
33
}
34
};
35
}
dius::tty
Definition
tty.h:6
dius::tty::WindowSize
Definition
tty.h:7
dius::tty::WindowSize::rows_shrinked
auto rows_shrinked(u32 r) -> WindowSize
Definition
tty.h:13
dius::tty::WindowSize::rows
u32 rows
Definition
tty.h:8
dius::tty::WindowSize::cols_shrinked
auto cols_shrinked(u32 c) -> WindowSize
Definition
tty.h:20
dius::tty::WindowSize::tag_invoke
constexpr friend auto tag_invoke(di::Tag< di::reflect >, di::InPlaceType< WindowSize >)
Definition
tty.h:29
dius::tty::WindowSize::operator==
auto operator==(WindowSize const &) const -> bool=default
dius::tty::WindowSize::cols
u32 cols
Definition
tty.h:9
dius::tty::WindowSize::pixel_width
u32 pixel_width
Definition
tty.h:10
dius::tty::WindowSize::pixel_height
u32 pixel_height
Definition
tty.h:11
generic
dius
tty.h
Generated by
1.13.2