1
0
mirror of https://gitlab.com/comunic/comunicterm synced 2024-12-25 13:08:54 +00:00

Can show an alert popup

This commit is contained in:
Pierre HUBERT 2020-01-08 21:03:38 +01:00
parent 981d58bcb9
commit 3f9215e28c
2 changed files with 41 additions and 2 deletions

View File

@ -15,9 +15,32 @@ void ui_utils::print_base_screen(WINDOW *w)
const string msg = "Light client";
mvprintw(0, (col-static_cast<int>(msg.length())), msg.c_str());
}
void ui_utils::alert(WINDOW *win, const string &msg)
{
erase();
print_base_screen(win);
int rows, cols;
getmaxyx(win, rows, cols);
int start = (rows/2) - 3;
mvwprintw(win, start, (cols-static_cast<int>(msg.length()))/2, msg.c_str());
wattron(stdscr, A_REVERSE);
mvwprintw(win, start+3, (cols-4)/2, " OK ");
wattroff(stdscr, A_REVERSE);
curs_set(0);
refresh();
while(getch() != 10);
curs_set(1);
erase();
refresh();
}

16
ui_utils.h Normal file
View File

@ -0,0 +1,16 @@
/**
* UI utilities
*
* @author Pierre HUBERT
*/
#include <ncurses.h>
#include <string>
#pragma once
namespace ui_utils {
void alert(WINDOW *win, const std::string &msg);
void print_base_screen(WINDOW *w);
}