Moved the language section to its own repository
Moved colors.{cc,h} into that repo as well and submoduled it.master
parent
d2724f2417
commit
fb793fff7c
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "ceevlang"]
|
||||||
|
path = ceevlang
|
||||||
|
url = https://sauce.nxi.no/dahrub/ceevlang.git
|
|
@ -18,8 +18,19 @@ execute_process(
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
find_package(SDL2 REQUIRED)
|
find_package(SDL2 REQUIRED)
|
||||||
include_directories(${SDL2_INCLUDE_DIRS})
|
include_directories(${SDL2_INCLUDE_DIRS})
|
||||||
add_executable(ceev src/ceev.cc src/ceev.h src/colors.cc src/colors.h)
|
|
||||||
target_link_libraries(ceev ${SDL2_LIBRARIES})
|
# Global lib config
|
||||||
|
add_executable(${PROJECT_NAME} src/ceev.cc src/ceev.h)
|
||||||
|
find_package(ceev REQUIRED)
|
||||||
|
include_directories(${ceev_INCLUDE_DIRS})
|
||||||
|
target_link_libraries(${PROJECT_NAME} ${ceev_LIBRARIES})
|
||||||
|
#endconfig
|
||||||
|
|
||||||
|
# Local lib config
|
||||||
|
# add_executable(${PROJECT_NAME} src/ceev.cc src/ceev.h src/colors.cc src/colors.h)
|
||||||
|
# endconfig
|
||||||
|
|
||||||
|
target_link_libraries(${PROJECT_NAME} ${SDL2_LIBRARIES})
|
||||||
|
|
||||||
target_compile_definitions(${PROJECT_NAME} PRIVATE
|
target_compile_definitions(${PROJECT_NAME} PRIVATE
|
||||||
"-DGIT_COMMIT_HASH=\"${GIT_COMMIT_HASH}\"")
|
"-DGIT_COMMIT_HASH=\"${GIT_COMMIT_HASH}\"")
|
||||||
|
@ -28,3 +39,5 @@ string(REPLACE "\n" "\\n" GIT_COMMIT_MSG "${GIT_COMMIT_MSG}")
|
||||||
|
|
||||||
target_compile_definitions(${PROJECT_NAME} PRIVATE
|
target_compile_definitions(${PROJECT_NAME} PRIVATE
|
||||||
"-DGIT_COMMIT_MSG=\"${GIT_COMMIT_MSG}\"")
|
"-DGIT_COMMIT_MSG=\"${GIT_COMMIT_MSG}\"")
|
||||||
|
|
||||||
|
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit b8d5dd56730f7f8465e418a39a1c31d1fa67daac
|
42
src/ceev.cc
42
src/ceev.cc
|
@ -1,5 +1,4 @@
|
||||||
#include "ceev.h"
|
#include "ceev.h"
|
||||||
|
|
||||||
int usage() {
|
int usage() {
|
||||||
std::cout << "Usage:";
|
std::cout << "Usage:";
|
||||||
std::cout << "\n\t";
|
std::cout << "\n\t";
|
||||||
|
@ -82,14 +81,16 @@ static std::string query_author() {
|
||||||
return author;
|
return author;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct config_data get_config() {
|
struct config_data get_config(bool ignore_err = false) {
|
||||||
fs::path config_path = fs::current_path();
|
fs::path config_path = fs::current_path();
|
||||||
std::string line;
|
std::string line;
|
||||||
struct config_data data;
|
struct config_data data;
|
||||||
std::ifstream config(config_path / ".ceev" / CONFIG_FILENAME);
|
std::ifstream config(config_path / ".ceev" / CONFIG_FILENAME);
|
||||||
if (!config) {
|
if (!config) {
|
||||||
std::cerr << bg_red(bold("ERROR")) << ": Could not open config\n";
|
if (!ignore_err) {
|
||||||
std::cerr << "Run `ceev init' to create a new project." << std::endl;
|
std::cerr << bg_red(bold("ERROR")) << ": Could not open config\n";
|
||||||
|
std::cerr << "Run `ceev init' to create a new project." << std::endl;
|
||||||
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
while (std::getline(config, line)) {
|
while (std::getline(config, line)) {
|
||||||
|
@ -190,6 +191,8 @@ int devel(std::deque<std::string> args) {
|
||||||
return devel_roadmap();
|
return devel_roadmap();
|
||||||
if (a1 == "sdl2")
|
if (a1 == "sdl2")
|
||||||
return devel_sdl2(args);
|
return devel_sdl2(args);
|
||||||
|
if (a1 == "lang")
|
||||||
|
return 1;
|
||||||
|
|
||||||
std::string kw;
|
std::string kw;
|
||||||
if (a1.substr(0, 2) == "--") {
|
if (a1.substr(0, 2) == "--") {
|
||||||
|
@ -222,13 +225,15 @@ int devel_help() {
|
||||||
std::cout << "Get info about the latest commit.";
|
std::cout << "Get info about the latest commit.";
|
||||||
// ceev devel sdl2
|
// ceev devel sdl2
|
||||||
std::cout << "\n*\t";
|
std::cout << "\n*\t";
|
||||||
std::cout << GET_PROGRAM_NAME() << " devel " << cyan("sdl2") << "\n";
|
std::cout << GET_PROGRAM_NAME() << " devel " << cyan("sdl2") << " <"
|
||||||
|
<< bright_green("--use-defaults") << "/" << bright_green("-D")
|
||||||
|
<< ">\n";
|
||||||
std::cout << "\t\t";
|
std::cout << "\t\t";
|
||||||
std::cout << "Tests of SDL2";
|
std::cout << "Tests of SDL2";
|
||||||
// ceev devel --help
|
// ceev devel --help
|
||||||
std::cout << "\n*\t";
|
std::cout << "\n*\t";
|
||||||
std::cout << GET_PROGRAM_NAME() << " devel " << cyan("--help") << "/"
|
std::cout << GET_PROGRAM_NAME() << " devel " << bright_green("--help") << "/"
|
||||||
<< cyan("-h") << "\n";
|
<< bright_green("-h") << "\n";
|
||||||
std::cout << "\t\t";
|
std::cout << "\t\t";
|
||||||
std::cout << "This help page.";
|
std::cout << "This help page.";
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
@ -256,24 +261,30 @@ int devel_roadmap() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int devel_sdl2(std::deque<std::string> args) {
|
int devel_sdl2(std::deque<std::string> args) {
|
||||||
struct config_data data = get_config();
|
struct config_data data;
|
||||||
if (data.name == "" &&
|
if (!args.empty() && (args[0] == "--use-defaults" || args[0] == "-D")) {
|
||||||
(args.empty() || args[0] != "--use-defaults" || args[0] != "-D")) {
|
data.name = "CeeV";
|
||||||
|
data.version = __ceev_version;
|
||||||
|
data.author = "User";
|
||||||
|
data.email = "user@example.org";
|
||||||
|
} else
|
||||||
|
data = get_config();
|
||||||
|
if (data.name == "")
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
const int SCREEN_WIDTH = 640;
|
const int SCREEN_WIDTH = 640;
|
||||||
const int SCREEN_HEIGHT = 480;
|
const int SCREEN_HEIGHT = 480;
|
||||||
SDL_Window *window = nullptr;
|
SDL_Window *window = nullptr;
|
||||||
SDL_Surface *screen_surface = nullptr;
|
SDL_Surface *screen_surface = nullptr;
|
||||||
SDL_Surface *img_surface = nullptr;
|
SDL_Surface *img_surface = nullptr;
|
||||||
return 0;
|
|
||||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||||
std::cerr << bg_red(bold("ERROR"))
|
std::cerr << bg_red(bold("ERROR"))
|
||||||
<< ": SDL could not initialize! SDL_Error: " << SDL_GetError()
|
<< ": SDL could not initialize! SDL_Error: " << SDL_GetError()
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
window = SDL_CreateWindow(data.name.c_str(), SDL_WINDOWPOS_UNDEFINED,
|
std::string name = data.name + " version " + data.version + " by " +
|
||||||
|
data.author + " <" + data.email + ">";
|
||||||
|
window = SDL_CreateWindow(name.c_str(), SDL_WINDOWPOS_UNDEFINED,
|
||||||
SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH,
|
SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH,
|
||||||
SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
|
SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
|
||||||
if (window == nullptr) {
|
if (window == nullptr) {
|
||||||
|
@ -311,9 +322,6 @@ int main(int argc, char **argv) {
|
||||||
for (int i = 1; i < argc; i++)
|
for (int i = 1; i < argc; i++)
|
||||||
args.push_back(std::string(argv[i]));
|
args.push_back(std::string(argv[i]));
|
||||||
std::string a1 = std::string(args[0]);
|
std::string a1 = std::string(args[0]);
|
||||||
// XXX: Is this really needed?
|
|
||||||
std::transform(a1.begin(), a1.end(), a1.begin(),
|
|
||||||
[](unsigned char c) { return std::tolower(c); });
|
|
||||||
args.pop_front();
|
args.pop_front();
|
||||||
if (a1 == "init") {
|
if (a1 == "init") {
|
||||||
return create_fs(args);
|
return create_fs(args);
|
||||||
|
@ -335,8 +343,6 @@ int main(int argc, char **argv) {
|
||||||
return show_help();
|
return show_help();
|
||||||
}
|
}
|
||||||
if (a1.substr(0, 1) == "-") {
|
if (a1.substr(0, 1) == "-") {
|
||||||
// TODO: Although not yet needed, add support for multiparams, like `ceev
|
|
||||||
// -hv' True, that doesn't make sense, that's why it's not yet needed.
|
|
||||||
kw = a1.substr(1);
|
kw = a1.substr(1);
|
||||||
if (kw == "v")
|
if (kw == "v")
|
||||||
return show_version();
|
return show_version();
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <ceev/colors.h>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
@ -10,7 +11,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include "colors.h"
|
/* #include "colors.h" */
|
||||||
|
|
||||||
#ifndef __ceev_version
|
#ifndef __ceev_version
|
||||||
#define __ceev_version "0.1.1-devel"
|
#define __ceev_version "0.1.1-devel"
|
||||||
|
@ -32,7 +33,6 @@
|
||||||
#ifdef __GLIBC__
|
#ifdef __GLIBC__
|
||||||
#define GET_PROGRAM_NAME() program_invocation_short_name
|
#define GET_PROGRAM_NAME() program_invocation_short_name
|
||||||
#else
|
#else
|
||||||
#include <cstdlib>
|
|
||||||
#define GET_PROGRAM_NAME() getprogname()
|
#define GET_PROGRAM_NAME() getprogname()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
#include "colors.h"
|
|
||||||
|
|
||||||
std::string black(std::string input) {return "\x1b[30m" + input + "\x1b[0m";}
|
|
||||||
std::string red(std::string input) {return "\x1b[31m" + input + "\x1b[0m";}
|
|
||||||
std::string green(std::string input) {return "\x1b[32m" + input + "\x1b[0m";}
|
|
||||||
std::string yellow(std::string input) {return "\x1b[33m" + input + "\x1b[0m";}
|
|
||||||
std::string blue(std::string input) {return "\x1b[34m" + input + "\x1b[0m";}
|
|
||||||
std::string magenta(std::string input) {return "\x1b[35m" + input + "\x1b[0m";}
|
|
||||||
std::string cyan(std::string input) {return "\x1b[36m" + input + "\x1b[0m";}
|
|
||||||
std::string white(std::string input) {return "\x1b[37m" + input + "\x1b[0m";}
|
|
||||||
std::string bright_black(std::string input) {return "\x1b[90m" + input + "\x1b[0m";}
|
|
||||||
std::string bright_red(std::string input) {return "\x1b[91m" + input + "\x1b[0m";}
|
|
||||||
std::string bright_green(std::string input) {return "\x1b[92m" + input + "\x1b[0m";}
|
|
||||||
std::string bright_yellow(std::string input) {return "\x1b[93m" + input + "\x1b[0m";}
|
|
||||||
std::string bright_blue(std::string input) {return "\x1b[94m" + input + "\x1b[0m";}
|
|
||||||
std::string bright_magenta(std::string input) {return "\x1b[95m" + input + "\x1b[0m";}
|
|
||||||
std::string bright_cyan(std::string input) {return "\x1b[96m" + input + "\x1b[0m";}
|
|
||||||
std::string bright_white(std::string input) {return "\x1b[97m" + input + "\x1b[0m";}
|
|
||||||
std::string bg_black(std::string input) {return "\x1b[40m" + input + "\x1b[0m";}
|
|
||||||
std::string bg_red(std::string input) {return "\x1b[41m" + input + "\x1b[0m";}
|
|
||||||
std::string bg_green(std::string input) {return "\x1b[42m" + input + "\x1b[0m";}
|
|
||||||
std::string bg_yellow(std::string input) {return "\x1b[43m" + input + "\x1b[0m";}
|
|
||||||
std::string bg_blue(std::string input) {return "\x1b[44m" + input + "\x1b[0m";}
|
|
||||||
std::string bg_magenta(std::string input) {return "\x1b[45m" + input + "\x1b[0m";}
|
|
||||||
std::string bg_cyan(std::string input) {return "\x1b[46m" + input + "\x1b[0m";}
|
|
||||||
std::string bg_white(std::string input) {return "\x1b[47m" + input + "\x1b[0m";}
|
|
||||||
std::string bg_bright_black(std::string input) {return "\x1b[100m" + input + "\x1b[0m";}
|
|
||||||
std::string bg_bright_red(std::string input) {return "\x1b[101m" + input + "\x1b[0m";}
|
|
||||||
std::string bg_bright_green(std::string input) {return "\x1b[102m" + input + "\x1b[0m";}
|
|
||||||
std::string bg_bright_yellow(std::string input) {return "\x1b[103m" + input + "\x1b[0m";}
|
|
||||||
std::string bg_bright_blue(std::string input) {return "\x1b[104m" + input + "\x1b[0m";}
|
|
||||||
std::string bg_bright_magenta(std::string input) {return "\x1b[105m" + input + "\x1b[0m";}
|
|
||||||
std::string bg_bright_cyan(std::string input) {return "\x1b[106m" + input + "\x1b[0m";}
|
|
||||||
std::string bg_bright_white(std::string input) {return "\x1b[107m" + input + "\x1b[0m";}
|
|
||||||
std::string bold(std::string input) {return "\x1b[1m" + input + "\x1b[0m";}
|
|
||||||
std::string underline(std::string input) {return "\x1b[4m" + input + "\x1b[0m";}
|
|
||||||
std::string reverse(std::string input) {return "\x1b[7m" + input + "\x1b[0m";}
|
|
39
src/colors.h
39
src/colors.h
|
@ -1,39 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
std::string black(std::string input);
|
|
||||||
std::string red(std::string input);
|
|
||||||
std::string green(std::string input);
|
|
||||||
std::string yellow(std::string input);
|
|
||||||
std::string blue(std::string input);
|
|
||||||
std::string magenta(std::string input);
|
|
||||||
std::string cyan(std::string input);
|
|
||||||
std::string white(std::string input);
|
|
||||||
std::string bright_black(std::string input);
|
|
||||||
std::string bright_red(std::string input);
|
|
||||||
std::string bright_green(std::string input);
|
|
||||||
std::string bright_yellow(std::string input);
|
|
||||||
std::string bright_blue(std::string input);
|
|
||||||
std::string bright_magenta(std::string input);
|
|
||||||
std::string bright_cyan(std::string input);
|
|
||||||
std::string bright_white(std::string input);
|
|
||||||
std::string bg_black(std::string input);
|
|
||||||
std::string bg_red(std::string input);
|
|
||||||
std::string bg_green(std::string input);
|
|
||||||
std::string bg_yellow(std::string input);
|
|
||||||
std::string bg_blue(std::string input);
|
|
||||||
std::string bg_magenta(std::string input);
|
|
||||||
std::string bg_cyan(std::string input);
|
|
||||||
std::string bg_white(std::string input);
|
|
||||||
std::string bg_bright_black(std::string input);
|
|
||||||
std::string bg_bright_red(std::string input);
|
|
||||||
std::string bg_bright_green(std::string input);
|
|
||||||
std::string bg_bright_yellow(std::string input);
|
|
||||||
std::string bg_bright_blue(std::string input);
|
|
||||||
std::string bg_bright_magenta(std::string input);
|
|
||||||
std::string bg_bright_cyan(std::string input);
|
|
||||||
std::string bg_bright_white(std::string input);
|
|
||||||
std::string bold(std::string input);
|
|
||||||
std::string underline(std::string input);
|
|
||||||
std::string reverse(std::string input);
|
|
Loading…
Reference in New Issue