end curses on exit, s:-
This commit is contained in:
+13
-5
@@ -46,14 +46,15 @@ namespace /* internal */
|
||||
|
||||
void unexpected_char(char c)
|
||||
{
|
||||
cerr << "Line " << line << ": Unexpected '" << c << "'\n";
|
||||
endwin();
|
||||
cerr << "Line " << line << ": Unexpected '" << c << std::endl;
|
||||
exit(1);
|
||||
/* throw 0; */
|
||||
}
|
||||
|
||||
void unexpected_end()
|
||||
{
|
||||
cerr << "Unexpected end of file";
|
||||
endwin();
|
||||
cerr << "Unexpected end of file" << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -166,7 +167,7 @@ namespace /* internal */
|
||||
else if(res.second == Nobody)
|
||||
res.second = cur_tree->findId(name.data())[same_name_index];
|
||||
else
|
||||
/* todo */exit(1);
|
||||
/* todo */TFT_EXIT(1);
|
||||
same_name_index = 0;
|
||||
name.clear();
|
||||
break;
|
||||
@@ -204,6 +205,12 @@ namespace /* internal */
|
||||
{
|
||||
switch(*it_data)
|
||||
{
|
||||
case '-':
|
||||
if(name.empty())
|
||||
res.push_back( cur_tree->last() );
|
||||
else
|
||||
unexpected_char('-');
|
||||
break;
|
||||
case ',':
|
||||
if(!name.empty())
|
||||
{
|
||||
@@ -216,7 +223,8 @@ namespace /* internal */
|
||||
break;
|
||||
case '\n':
|
||||
++line;
|
||||
res.push_back( cur_tree->findId(name.data())[same_name_index] );
|
||||
if(!name.empty())
|
||||
res.push_back( cur_tree->findId(name.data())[same_name_index] );
|
||||
return res;
|
||||
case '_':
|
||||
name.push_back(' ');
|
||||
|
||||
+3
-64
@@ -1,13 +1,11 @@
|
||||
#include <ncursesw/ncurses.h>
|
||||
#include <iostream>
|
||||
#include "tree.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "parser.hpp"
|
||||
#include <ncursesw/ncurses.h>
|
||||
#include <string_view>
|
||||
#include <iostream>
|
||||
|
||||
using std::string_view;
|
||||
/* using std::cin; */
|
||||
/* using std::cout; */
|
||||
using std::cerr;
|
||||
using namespace std::literals;
|
||||
|
||||
@@ -33,62 +31,6 @@ int main(int argc, char* argv[])
|
||||
parseTftFile(file).display();
|
||||
}
|
||||
|
||||
Tree test1("Dechkovi");
|
||||
/* test1.loadFromFile(); */
|
||||
|
||||
|
||||
test1.addPerson("Rumen", M, Nobody, Nobody, {1968, 8, 9});
|
||||
test1.addPerson("Nadejda", F, Nobody, Nobody, {1972, 12, 15});
|
||||
test1.addRelation(0, Spouse, 1);
|
||||
test1.addPerson("Venelin", M, 0, 1, {1998, 6, 9});
|
||||
test1.addPerson("Vasil", M, 0, 1, {2001, 1, 16});
|
||||
/* test1.saveToFile(); */
|
||||
|
||||
Tree test2("Karamanovi");
|
||||
test2.addPerson("Vasil Dimitrov", M, Nobody, Nobody, {1941, 5, 18});
|
||||
test2.addPerson("Maria", F);
|
||||
test2.addRelation(0, Spouse, 1);
|
||||
test2.addPerson("Dimitar", M, 0, 1);
|
||||
test2.addPerson("Nadejda", F, 0, 1, {1972, 12, 15});
|
||||
test2.addPerson("Branimira", F);
|
||||
test2.addRelation(2, Spouse, 4);
|
||||
test2.addPerson("Ioan", M, 2, 4);
|
||||
test2.addPerson("Rumiana", F, 2, 4);
|
||||
|
||||
test1.display();
|
||||
test2.display();
|
||||
|
||||
(test2 + test1).display();
|
||||
|
||||
/* Tree firstTree("firstTree"); */
|
||||
/* firstTree.addPerson("Адам", M, Nobody, Nobody, {0, 1, 6}); */
|
||||
/* firstTree.addPerson("Ева", F, Nobody, Nobody, {0, 1, 6}); */
|
||||
/* firstTree.addRelation(0, Spouse, 1); */
|
||||
|
||||
/* firstTree.addPerson("Кайн", M, 0, 1); */
|
||||
|
||||
/* firstTree.addPerson("Авел", M, 0, 1); */
|
||||
/* firstTree.addRelation(2, Sibling, 3); */
|
||||
|
||||
/* firstTree.addPerson("Сит", M, 0, 1, 230); */
|
||||
/* firstTree.addRelation(2, Sibling, 4); */
|
||||
/* firstTree.addPerson("Енос", M, 4, Nobody, 435); */
|
||||
/* firstTree.addPerson("Каинан", M, 5 , Nobody, 605); */
|
||||
/* firstTree.addPerson("Малелеил", M, 6, Nobody, 605); */
|
||||
|
||||
|
||||
/* firstTree.addPerson("Енох", M, 3 , Nobody); */
|
||||
/* firstTree.addPerson("Гаидад", M, 8 , Nobody); */
|
||||
/* firstTree.addPerson("Малелеил", M, 9, Nobody); */
|
||||
|
||||
|
||||
/* firstTree.print(); */
|
||||
/* firstTree.display(); */
|
||||
|
||||
/* firstTree.printRel(3); */
|
||||
/* firstTree.printOldestAncestors(3); */
|
||||
|
||||
|
||||
/* ====================================================== */
|
||||
|
||||
/* std::vector<Tree> trees; */
|
||||
@@ -302,8 +244,5 @@ int main(int argc, char* argv[])
|
||||
|
||||
/* } while (!quit); */
|
||||
|
||||
endwin(); /* stop ncursers */
|
||||
|
||||
|
||||
return 0;
|
||||
/* TFT_EXIT(0); */
|
||||
}
|
||||
|
||||
+9
-2
@@ -11,8 +11,9 @@ void init()
|
||||
setlocale(LC_ALL, "en_US.UTF-8");
|
||||
|
||||
/* Init ncurses */
|
||||
initscr(); /* Start curses mode */
|
||||
curs_set(0); /* Hide cursor */
|
||||
initscr(); /* start curses mode */
|
||||
atexit( (void(*)())endwin ); /* stop curses at exit */
|
||||
curs_set(0); /* Hide cursor */
|
||||
noecho();
|
||||
cbreak(); /* get input instantly */
|
||||
keypad(stdscr, true);
|
||||
@@ -26,6 +27,12 @@ void init()
|
||||
wnoutrefresh(stdscr); /* if not present the first real refresh is missed */
|
||||
}
|
||||
|
||||
void TFT_EXIT(I32 return_code)
|
||||
{
|
||||
endwin(); /* stop ncursers */
|
||||
exit(return_code);
|
||||
}
|
||||
|
||||
MappedFile mapfile(fd_t file)
|
||||
{
|
||||
MappedFile res;
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ struct MappedFile
|
||||
};
|
||||
|
||||
void init();
|
||||
|
||||
void TFT_EXIT(I32 return_code);
|
||||
|
||||
MappedFile mapfile(fd_t);
|
||||
fd_t openOrDie(const char* path);
|
||||
|
||||
Reference in New Issue
Block a user