blob: 91c07da88218b5d1c21ab61ecff4ab35c70fe8fb [file] [log] [blame]
Adedeji Adebisi12c5f112021-07-22 18:07:52 +00001// Copyright 2021 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include "bargraph.hpp"
18
19#include <ncurses.h>
20
21#include <string>
22
23const int INVALID = -999; // Constant indicating invalid indices
24struct Rect
25{
26 int x, y, w, h; // X, Y, Width, Height
27 Rect(int _x, int _y, int _w, int _h) : x(_x), y(_y), w(_w), h(_h)
28 {}
29 Rect() : x(0), y(0), w(1), h(1)
30 {}
31};
32
33int DrawTextWithWidthLimit(WINDOW* win, std::string txt, int y, int x,
34 int width, const std::string& delimiters);
35std::string FloatToString(float value);
36template <typename T>
37void HistoryBarGraph(WINDOW* win, const Rect& rect, BarGraph<T>* bargraph);