Init cursen
This commit is contained in:
parent
3e3122bc12
commit
39cefab611
|
|
@ -1,6 +1,6 @@
|
|||
cmake_minimum_required(VERSION 3.23)
|
||||
|
||||
project(template)
|
||||
project(cursen)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
|
@ -8,9 +8,16 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|||
#string(REPLACE ":" ";" INCLUDE_LIST $ENV{CMAKE_STDLIB})
|
||||
#include_directories($ENV{CMAKE_STDLIB})
|
||||
|
||||
add_executable(template)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
target_sources(template
|
||||
pkg_check_modules(notcurses REQUIRED IMPORTED_TARGET notcurses)
|
||||
pkg_check_modules(notcurses++ REQUIRED IMPORTED_TARGET notcurses++)
|
||||
|
||||
add_executable(cursen)
|
||||
|
||||
target_link_libraries(cursen PRIVATE PkgConfig::notcurses PkgConfig::notcurses++)
|
||||
|
||||
target_sources(cursen
|
||||
PRIVATE
|
||||
main.cpp
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
* Nix C++ Dev Template
|
||||
Basic C++ CMake template with Nix
|
||||
* Cursen
|
||||
|
|
|
|||
|
|
@ -1,14 +1,17 @@
|
|||
with (import <nixpkgs> {});
|
||||
|
||||
clangStdenv.mkDerivation {
|
||||
name = "template";
|
||||
name = "cursen";
|
||||
nativeBuildInputs = with pkgs; [
|
||||
cmake
|
||||
pkg-config
|
||||
|
||||
notcurses.dev
|
||||
|
||||
clang-tools
|
||||
clang
|
||||
];
|
||||
|
||||
# Workaround as Clangd cannot see std header files, so include set of files manually just for Clangd
|
||||
CXXFLAGS = "-isystem${pkgs.gcc.cc}/include/c++/14.3.0 -isystem${pkgs.gcc.cc}/include/c++/14.3.0/x86_64-unknown-linux-gnu -isystem${pkgs.glibc.dev}/include";
|
||||
CXXFLAGS = "-isystem${pkgs.gcc.cc}/include/c++/14.3.0 -isystem${pkgs.gcc.cc}/include/c++/14.3.0/x86_64-unknown-linux-gnu -isystem${pkgs.glibc.dev}/include -I${notcurses.dev}";
|
||||
}
|
||||
|
|
|
|||
80
main.cpp
80
main.cpp
|
|
@ -1,6 +1,82 @@
|
|||
#include <iostream>
|
||||
#include <ncpp/NotCurses.hh>
|
||||
|
||||
int main() {
|
||||
std::cout << "Hello, world!" << std::endl;
|
||||
using namespace ncpp;
|
||||
|
||||
typedef union Grapheme {
|
||||
uint8_t utf8[4];
|
||||
uint32_t to_uint32 = 0;
|
||||
} Grapheme;
|
||||
|
||||
inline uint32_t utf32_to_egc(const uint32_t character) {
|
||||
Grapheme result;
|
||||
|
||||
if (!notcurses_ucs32_to_utf8(&character, 1, result.utf8, 4)) {
|
||||
std::cerr << "Couldn't convert ucs32 " + std::to_string(character) + "to utf8!" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
};
|
||||
|
||||
return result.to_uint32;
|
||||
}
|
||||
|
||||
int run ()
|
||||
{
|
||||
NotCurses nc;
|
||||
Plane* nc_plane = nc.get_stdplane();
|
||||
|
||||
Cell corner_ul = Cell(utf32_to_egc(L'┌'));
|
||||
Cell corner_ur = Cell(utf32_to_egc(L'┐'));
|
||||
Cell corner_bl = Cell(utf32_to_egc(L'└'));
|
||||
Cell corner_br = Cell(utf32_to_egc(L'┘'));
|
||||
Cell horizontal_line = Cell(utf32_to_egc(L'─'));
|
||||
Cell vertical_line = Cell(utf32_to_egc(L'│'));
|
||||
nc_plane->perimeter(
|
||||
corner_ul,
|
||||
corner_ur,
|
||||
corner_bl,
|
||||
corner_br,
|
||||
horizontal_line,
|
||||
vertical_line,
|
||||
0
|
||||
);
|
||||
|
||||
nc_plane->putstr(0, 1, "channel");
|
||||
|
||||
nc_plane->putstr(1, 1, "─");
|
||||
|
||||
/*nc_plane->cursor_move(0, 0);
|
||||
Cell start; nc_plane->get_at(0, 0, start);
|
||||
//nc_plane->get_at(0, 0, &end);
|
||||
nc_plane->vline(
|
||||
start,
|
||||
10
|
||||
);*/
|
||||
|
||||
while (true) {
|
||||
|
||||
nc.render();
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main ()
|
||||
{
|
||||
if (!setlocale (LC_ALL, "")){
|
||||
std::cerr << "Couldn't set locale based on user preferences" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
try {
|
||||
return run ();
|
||||
} catch (ncpp::init_error &e) {
|
||||
std::cerr << "Initialization error: " << e.what () << std::endl;
|
||||
} catch (ncpp::invalid_state_error &e) {
|
||||
std::cerr << "Invalid state error: " << e.what () << std::endl;
|
||||
} catch (ncpp::invalid_argument &e) {
|
||||
std::cerr << "Invalid argument error: " << e.what () << std::endl;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue