resize & signal handler
This commit is contained in:
parent
793f8a8370
commit
9f4aebef64
9 changed files with 117 additions and 30 deletions
|
@ -5,7 +5,10 @@ WINDOW* View::win = nullptr;
|
|||
View::View()
|
||||
{
|
||||
if(!win)
|
||||
throw std::runtime_error("View::win not initialized, missing context!");
|
||||
{
|
||||
ERR_MSG = "View::win not initialized, missing context!";
|
||||
raise(SIGINT);
|
||||
}
|
||||
getmaxyx(win, height, width); // init width and height
|
||||
keypad(win, TRUE);
|
||||
}
|
||||
|
@ -42,7 +45,7 @@ void View::repaint()
|
|||
start_y = floor((size.ws_row - height) / 2.);
|
||||
|
||||
mvwin(win, start_y, start_x);
|
||||
|
||||
clear();
|
||||
wclear(win);
|
||||
|
||||
// generic draw
|
||||
|
@ -56,3 +59,20 @@ void View::repaint()
|
|||
refresh();
|
||||
wrefresh(win);
|
||||
}
|
||||
|
||||
// from: https://stackoverflow.com/a/37454181
|
||||
std::vector<std::string> View::str_split(const std::string& str, const std::string delim)
|
||||
{
|
||||
std::vector<std::string> tokens;
|
||||
size_t prev = 0, pos = 0;
|
||||
do
|
||||
{
|
||||
pos = str.find(delim, prev);
|
||||
if (pos == std::string::npos) pos = str.length();
|
||||
std::string token = str.substr(prev, pos-prev);
|
||||
if (!token.empty()) tokens.push_back(token);
|
||||
prev = pos + delim.length();
|
||||
}
|
||||
while (pos < str.length() && prev < str.length());
|
||||
return tokens;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue