Skip to content
This repository has been archived by the owner on Sep 25, 2022. It is now read-only.

Commit

Permalink
Add: Dynamic_title example, and Tools
Browse files Browse the repository at this point in the history
  • Loading branch information
ferhatgec committed Aug 22, 2020
1 parent 4c8dba2 commit e2235e9
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 6 deletions.
Binary file modified fla
Binary file not shown.
28 changes: 28 additions & 0 deletions flascript/Interpreter/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ FFunction func;

int fprintf(const char *format, ...);

void SetTitle(std::string title);


/*
Standart:
print(string) -> Hello World! <-
Expand Down Expand Up @@ -138,6 +141,23 @@ FPrint::Print(std::string file, std::string arg) {
}
}
}
} else if(assign == "dynamic") {
/*
print(dynamic) -> set[title] -> "Hello world!" <-
*/
std::string type;
inp.GetBtwString(arg, "set[", "]", type);
if(type == "title") {
inp.GetBtwString(arg, "\"", "\"", type);
if(type != "error") {
SetTitle(type);
} else {
std::cout << "print : dynamic : \"......\" : Parse error.\n";
std::cout << " ^^^^^^^^^\n";
}
} else {
std::cout << type << " : Not defined type.\n";
}
} else if(inp.FindObject(assign, "get") == true) {
// print(get[string] -> test ->) ->this
std::string get;
Expand Down Expand Up @@ -278,3 +298,11 @@ int fprintf(const char *format, ...) {
va_end (arg);
return done;
}

/*
Terminal title
*/

void SetTitle(std::string title) {
std::cout << "\e]2; " + title + " \a";
}
33 changes: 33 additions & 0 deletions flascript/Interpreter/Tools.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* MIT License
#
# Copyright (c) 2020 Ferhat Geçdoğan All Rights Reserved.
# Distributed under the terms of the MIT License.
#
# */

#include <sstream>
#include <fstream>
#include <iostream>
#include <FlaVersion.hpp>
#include <Tokenizer.hpp>
#include <Interpreter/Interpreter.hpp>
#include <Interpreter/Read.hpp>
#include <Interpreter/Tools.hpp>

// Libraries
#include <FileSystemPlusPlus.h>
#include <Colorized.hpp>
#include <SystemInfo.hpp>

#ifdef WINDOWS
#include <direct.h>
#define GetCurrentDir _getcwd
#else
#include <unistd.h>
#define GetCurrentDir getcwd
#endif

void
FTools::TextBackground(int color) {
printf("%c[%dm", ESC, 40+color);
}
19 changes: 19 additions & 0 deletions include/Interpreter/Tools.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* MIT License
#
# Copyright (c) 2020 Ferhat Geçdoğan All Rights Reserved.
# Distributed under the terms of the MIT License.
#
# */

#ifndef TOOLS_HPP
#define TOOLS_HPP

#include <iostream>
#include <cstring>

class FTools {
public:
void TextBackground(int);
};

#endif // TOOLS_HPP
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
g++ -I./Library/ -I./include/ ./flascript/Interpreter/Interpreter.cpp ./flascript/Interpreter/Definitions.cpp ./flascript/Interpreter/Exec.cpp \
./flascript/Interpreter/Read.cpp ./flascript/Interpreter/Print.cpp ./flascript/Interpreter/String.cpp \
./flascript/Interpreter/Function.cpp ./flascript/Interpreter/Import.cpp ./flascript/FlaVersion.cpp \
./flascript/FlaScriptMain.cpp -o fla && ./fla --b ./init/install.fls
./flascript/Interpreter/Tools.cpp ./flascript/FlaScriptMain.cpp -o fla && ./fla --b ./init/install.fls
2 changes: 1 addition & 1 deletion make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
g++ -I./Library/ -I./include/ ./flascript/Interpreter/Interpreter.cpp ./flascript/Interpreter/Definitions.cpp ./flascript/Interpreter/Exec.cpp \
./flascript/Interpreter/Read.cpp ./flascript/Interpreter/Print.cpp ./flascript/Interpreter/String.cpp \
./flascript/Interpreter/Function.cpp ./flascript/Interpreter/Import.cpp ./flascript/FlaVersion.cpp \
./flascript/FlaScriptMain.cpp -o fla && ./fla --b test.fls
./flascript/Interpreter/Tools.cpp ./flascript/FlaScriptMain.cpp -o fla && ./fla --b test.fls
5 changes: 1 addition & 4 deletions test.fls
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import(<info/SystemInfo.flsh>) -> time <-
main() -> main {
print(string) -> "Time: "
put[time -> func -> GetTime() <-]
print(newline)
print(dynamic) -> set[title] -> "Hello World, Terminal :)" <-
}
3 changes: 3 additions & 0 deletions test/dynamic_title.fls
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
main() -> main {
print(dynamic) -> set[title] -> "Hello World, Terminal :)" <-
}

0 comments on commit e2235e9

Please sign in to comment.