sqlite from installed library
4f1f5a9 parent: edf35e1 modified
CMakeLists.txt +2 -2 | @@ -23,12 +23,12 @@ find_package(SQLite3 REQUIRED) | ||
| 23 | 23 | |
| 24 | 24 | include_directories(${CMAKE_SOURCE_DIR}/include) |
| 25 | 25 | |
| 26 | -add_executable(fluffy src/main.cpp src/sqlite3.c) | |
| 26 | +add_executable(fluffy src/main.cpp) | |
| 27 | 27 | |
| 28 | 28 | target_link_libraries(fluffy |
| 29 | 29 | PRIVATE ftxui::screen |
| 30 | 30 | PRIVATE ftxui::dom |
| 31 | - PRIVATE ftxui::component # Not needed for this example. | |
| 31 | + PRIVATE ftxui::component | |
| 32 | 32 | PRIVATE SQLite::SQLite3 |
| 33 | 33 | ) |
| 34 | 34 | |
| @@ -23,12 +23,12 @@ find_package(SQLite3 REQUIRED) | |||
| 23 | 23 | ||
| 24 | include_directories(${CMAKE_SOURCE_DIR}/include) | 24 | include_directories(${CMAKE_SOURCE_DIR}/include) |
| 25 | 25 | ||
| 26 | -add_executable(fluffy src/main.cpp src/sqlite3.c) | 26 | +add_executable(fluffy src/main.cpp) |
| 27 | 27 | ||
| 28 | target_link_libraries(fluffy | 28 | target_link_libraries(fluffy |
| 29 | PRIVATE ftxui::screen | 29 | PRIVATE ftxui::screen |
| 30 | PRIVATE ftxui::dom | 30 | PRIVATE ftxui::dom |
| 31 | - PRIVATE ftxui::component # Not needed for this example. | 31 | + PRIVATE ftxui::component |
| 32 | PRIVATE SQLite::SQLite3 | 32 | PRIVATE SQLite::SQLite3 |
| 33 | ) | 33 | ) |
| 34 | 34 | ||
modified
src/main.cpp +10 -13 | @@ -6,7 +6,7 @@ | ||
| 6 | 6 | #include <string> |
| 7 | 7 | #include <cstdlib> |
| 8 | 8 | #include <filesystem> |
| 9 | -#include <../include/sqlite3.h> | |
| 9 | +#include <sqlite3.h> | |
| 10 | 10 | #include <map> |
| 11 | 11 | |
| 12 | 12 | |
| @@ -89,10 +89,8 @@ int main() { | ||
| 89 | 89 | const unsigned char* gamePath = sqlite3_column_text(stmt, 2); |
| 90 | 90 | |
| 91 | 91 | std::cout << gameName << ": " << gamePath << std::endl; |
| 92 | - std::string name{}; | |
| 93 | - std::string path{}; | |
| 94 | - name.append(reinterpret_cast<const char*>(gameName)); | |
| 95 | - path.append(reinterpret_cast<const char*>(gamePath)); | |
| 92 | + std::string name{reinterpret_cast<const char*>(gameName)}; | |
| 93 | + std::string path{reinterpret_cast<const char*>(gamePath)}; | |
| 96 | 94 | games[name] = path; |
| 97 | 95 | } |
| 98 | 96 | sqlite3_finalize(stmt); |
| @@ -107,16 +105,15 @@ int main() { | ||
| 107 | 105 | |
| 108 | 106 | auto summary = [&] { |
| 109 | 107 | auto content = vbox(localGames); |
| 110 | - return window(text(L" Fluffy v0.1 "), content); | |
| 108 | + return window(text(L" Games "), content); | |
| 111 | 109 | }; |
| 112 | 110 | |
| 113 | - auto document = // | |
| 114 | - vbox({ | |
| 115 | - summary(), | |
| 116 | - }); | |
| 117 | - | |
| 118 | - // Limit the size of the document to 80 char. | |
| 119 | - document = document | size(WIDTH, LESS_THAN, 80); | |
| 111 | + auto document = vbox({ | |
| 112 | + text(L" Fluffy v0.1 "), | |
| 113 | + vbox({summary()}), | |
| 114 | + }); | |
| 115 | + | |
| 116 | + document = document | size(WIDTH, LESS_THAN, 120); | |
| 120 | 117 | |
| 121 | 118 | auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document)); |
| 122 | 119 | Render(screen, document); |
| @@ -6,7 +6,7 @@ | |||
| 6 | #include <string> | 6 | #include <string> |
| 7 | #include <cstdlib> | 7 | #include <cstdlib> |
| 8 | #include <filesystem> | 8 | #include <filesystem> |
| 9 | -#include <../include/sqlite3.h> | 9 | +#include <sqlite3.h> |
| 10 | #include <map> | 10 | #include <map> |
| 11 | 11 | ||
| 12 | 12 | ||
| @@ -89,10 +89,8 @@ int main() { | |||
| 89 | const unsigned char* gamePath = sqlite3_column_text(stmt, 2); | 89 | const unsigned char* gamePath = sqlite3_column_text(stmt, 2); |
| 90 | 90 | ||
| 91 | std::cout << gameName << ": " << gamePath << std::endl; | 91 | std::cout << gameName << ": " << gamePath << std::endl; |
| 92 | - std::string name{}; | 92 | + std::string name{reinterpret_cast<const char*>(gameName)}; |
| 93 | - std::string path{}; | 93 | + std::string path{reinterpret_cast<const char*>(gamePath)}; |
| 94 | - name.append(reinterpret_cast<const char*>(gameName)); | ||
| 95 | - path.append(reinterpret_cast<const char*>(gamePath)); | ||
| 96 | games[name] = path; | 94 | games[name] = path; |
| 97 | } | 95 | } |
| 98 | sqlite3_finalize(stmt); | 96 | sqlite3_finalize(stmt); |
| @@ -107,16 +105,15 @@ int main() { | |||
| 107 | 105 | ||
| 108 | auto summary = [&] { | 106 | auto summary = [&] { |
| 109 | auto content = vbox(localGames); | 107 | auto content = vbox(localGames); |
| 110 | - return window(text(L" Fluffy v0.1 "), content); | 108 | + return window(text(L" Games "), content); |
| 111 | }; | 109 | }; |
| 112 | 110 | ||
| 113 | - auto document = // | 111 | + auto document = vbox({ |
| 114 | - vbox({ | 112 | + text(L" Fluffy v0.1 "), |
| 115 | - summary(), | 113 | + vbox({summary()}), |
| 116 | - }); | 114 | + }); |
| 117 | - | 115 | + |
| 118 | - // Limit the size of the document to 80 char. | 116 | + document = document | size(WIDTH, LESS_THAN, 120); |
| 119 | - document = document | size(WIDTH, LESS_THAN, 80); | ||
| 120 | 117 | ||
| 121 | auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document)); | 118 | auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document)); |
| 122 | Render(screen, document); | 119 | Render(screen, document); |