|
@@ -1,7 +1,6 @@
|
|
|
#include<iostream>
|
|
#include<iostream>
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
#include <unistd.h>
|
|
|
-#include <ncurses.h>
|
|
|
|
|
#include <utility>
|
|
#include <utility>
|
|
|
#include "curseOutput.hh"
|
|
#include "curseOutput.hh"
|
|
|
#include "jsonObject.hh"
|
|
#include "jsonObject.hh"
|
|
@@ -33,13 +32,20 @@ void CurseOutput::redraw()
|
|
|
|
|
|
|
|
select_up = select_down = nullptr;
|
|
select_up = select_down = nullptr;
|
|
|
selectFound = false;
|
|
selectFound = false;
|
|
|
|
|
+ getScreenSize(screenSize);
|
|
|
redraw(cursor, screenSize, topleft.second);
|
|
redraw(cursor, screenSize, topleft.second);
|
|
|
|
|
+ move(screenSize.second, screenSize.first);
|
|
|
if (!select_down)
|
|
if (!select_down)
|
|
|
select_down = selection;
|
|
select_down = selection;
|
|
|
if (!select_up)
|
|
if (!select_up)
|
|
|
select_up = selection;
|
|
select_up = selection;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+void CurseOutput::getScreenSize(std::pair<int, int> &ss)
|
|
|
|
|
+{
|
|
|
|
|
+ getmaxyx(stdscr, ss.second, ss.first);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
CurseOutput::t_nextKey CurseOutput::findNext(const JSonElement *item)
|
|
CurseOutput::t_nextKey CurseOutput::findNext(const JSonElement *item)
|
|
|
{
|
|
{
|
|
|
const JSonContainer *parent = item->getParent();
|
|
const JSonContainer *parent = item->getParent();
|
|
@@ -233,15 +239,29 @@ void CurseOutput::init()
|
|
|
noecho();
|
|
noecho();
|
|
|
cbreak();
|
|
cbreak();
|
|
|
clear();
|
|
clear();
|
|
|
- keypad(stdscr, true);
|
|
|
|
|
curs_set(false);
|
|
curs_set(false);
|
|
|
nodelay(stdscr, true);
|
|
nodelay(stdscr, true);
|
|
|
|
|
+ if (!isatty(fileno(stdin)) || !isatty(fileno(stdout)))
|
|
|
|
|
+ {
|
|
|
|
|
+ screen_fd = fopen("/dev/tty", "r+");
|
|
|
|
|
+ setbuf(screen_fd, nullptr);
|
|
|
|
|
+ screen = newterm(nullptr, screen_fd, screen_fd);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ screen = newterm(nullptr, stdout, stdin);
|
|
|
|
|
+ keypad(stdscr, true);
|
|
|
topleft.first = std::pair<unsigned int, unsigned int>(0, 0);
|
|
topleft.first = std::pair<unsigned int, unsigned int>(0, 0);
|
|
|
topleft.second = data;
|
|
topleft.second = data;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void CurseOutput::shutdown()
|
|
void CurseOutput::shutdown()
|
|
|
{
|
|
{
|
|
|
|
|
+ delscreen(screen);
|
|
|
endwin();
|
|
endwin();
|
|
|
|
|
+ if (screen_fd)
|
|
|
|
|
+ {
|
|
|
|
|
+ fclose(screen_fd);
|
|
|
|
|
+ screen_fd = nullptr;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|