fix and update readme
This commit is contained in:
+10
-13
@@ -1,24 +1,24 @@
|
|||||||
tft - Terminal Family Tree
|
tft - Terminal Family Tree
|
||||||
|
|
||||||
tft can create and display family trees on the terminal.
|
tft is an ncurses program that can create and display family trees on the terminal.
|
||||||
|
|
||||||
|
|
||||||
HOW TO CREATE:
|
HOW TO CREATE:
|
||||||
Trees are created using the tft file format, for example this tft file:
|
Trees are created using the tft file format, for example this tft file:
|
||||||
|
|
||||||
# This is a comment
|
# This is a comment
|
||||||
Adam, M # Adam is a male
|
Adam
|
||||||
|
|
||||||
Eve, F
|
Eve, F # Eve is female
|
||||||
s: Adam # Eve's spouse is Adam
|
s: Adam # Eve's spouse is Adam
|
||||||
|
|
||||||
Cain, M
|
Cain
|
||||||
p: Adam, Eve # Cain's parents are Adam and Eve
|
p: Adam, Eve # Cain's parents are Adam and Eve
|
||||||
|
|
||||||
Abel, M
|
Abel
|
||||||
p: - # Abel's parents are the same as the last person's (Cain)
|
p: - # Abel's parents are the same as the last person's (Cain)
|
||||||
|
|
||||||
Seth, M
|
Seth
|
||||||
p: -
|
p: -
|
||||||
|
|
||||||
|
|
||||||
@@ -43,10 +43,10 @@ DEPENDENCIES:
|
|||||||
ncursesw development library (libncursesw5-dev on Debian/Ubuntu)
|
ncursesw development library (libncursesw5-dev on Debian/Ubuntu)
|
||||||
|
|
||||||
HOW TO INSTALL:
|
HOW TO INSTALL:
|
||||||
Make sure you satisfy the dependencies and have permissons and execute:
|
Make sure you satisfy the dependencies and execute:
|
||||||
git clone https://gitlab.com/venelin98/tft.git
|
git clone https://gitlab.com/venelin98/tft.git
|
||||||
cd tft
|
cd tft
|
||||||
./install.sh
|
sudo ./install.sh
|
||||||
|
|
||||||
|
|
||||||
HOW TO USE:
|
HOW TO USE:
|
||||||
@@ -60,11 +60,8 @@ HOW TO USE:
|
|||||||
- - show first names only
|
- - show first names only
|
||||||
|
|
||||||
TFT FORMAT:
|
TFT FORMAT:
|
||||||
- All spaces are ignored e.g.: Adam 0 and Adam0 are equivalent
|
- A number after a name is used to disambiguate when multiple people have identical names e.g.:
|
||||||
- '_' in names is converted to ' '
|
"Adam 0" is the first added Adam, "Adam 1" is the second added Adam
|
||||||
- Number at the end of a name is used to disambiguate when multiple people have identical names e.g.:
|
|
||||||
Adam0 is the first added Adam, Adam1 is the second added Adam
|
|
||||||
- Must end with a newline
|
|
||||||
|
|
||||||
QUESTIONS AND FEEDBACK:
|
QUESTIONS AND FEEDBACK:
|
||||||
venelin98@abv.bg
|
venelin98@abv.bg
|
||||||
|
|||||||
+18
-6
@@ -22,6 +22,13 @@ namespace /* internal */
|
|||||||
: data(new char[len])
|
: data(new char[len])
|
||||||
, end(data + len)
|
, end(data + len)
|
||||||
{}
|
{}
|
||||||
|
alloced(const alloced&) = delete;
|
||||||
|
alloced(alloced&& other)
|
||||||
|
: data(other.data)
|
||||||
|
, end(other.end)
|
||||||
|
{
|
||||||
|
const_cast<char*&>(other.data) = nullptr;
|
||||||
|
}
|
||||||
~alloced()
|
~alloced()
|
||||||
{
|
{
|
||||||
delete[] data;
|
delete[] data;
|
||||||
@@ -42,6 +49,11 @@ namespace /* internal */
|
|||||||
struct token
|
struct token
|
||||||
{
|
{
|
||||||
token(const char* b, const char* e);
|
token(const char* b, const char* e);
|
||||||
|
explicit token(TokenType t)
|
||||||
|
: type(t)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
U32 size() const
|
U32 size() const
|
||||||
{
|
{
|
||||||
return end - begin;
|
return end - begin;
|
||||||
@@ -512,13 +524,13 @@ namespace /* internal */
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<token> tokenize(alloced file)
|
vector<token> tokenize(const char* data_begin, const char* data_end)
|
||||||
{
|
{
|
||||||
vector<token> tokens;
|
vector<token> tokens;
|
||||||
tokens.reserve(256);
|
tokens.reserve(256);
|
||||||
char* token_begin = file.data;
|
const char* token_begin = data_begin;
|
||||||
|
|
||||||
for(char* it = file.data; it < end_data_; ++it)
|
for(const char* it = data_begin; it < data_end; ++it)
|
||||||
{
|
{
|
||||||
switch(*it)
|
switch(*it)
|
||||||
{
|
{
|
||||||
@@ -545,8 +557,8 @@ namespace /* internal */
|
|||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* tokens.emplace_back(nullptr, nullptr); */
|
tokens.emplace_back(NEW_LINE);
|
||||||
/* tokens.back().type = NEW_LINE; */
|
tokens.emplace_back(NEW_LINE);
|
||||||
return tokens;
|
return tokens;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -561,7 +573,7 @@ Tree parseTftFile(const char* path)
|
|||||||
|
|
||||||
MappedFile mapedfile = mapfile(file);
|
MappedFile mapedfile = mapfile(file);
|
||||||
alloced preprocessed = removeComments(mapedfile);
|
alloced preprocessed = removeComments(mapedfile);
|
||||||
vector<token> tokens = tokenize(preprocessed);
|
vector<token> tokens = tokenize(preprocessed.data, end_data_);
|
||||||
|
|
||||||
state_neutral(tokens);
|
state_neutral(tokens);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user