aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRichard Qin <richard.qin.x@gmail.com>2026-04-11 00:50:38 +0800
committerRichard Qin <richard.qin.x@gmail.com>2026-04-11 00:50:38 +0800
commit44ad3c8b36540c6b0b3144a21ac40310e163bb19 (patch)
treeec2b75f68771fcbed8ba7450d30da1f05ebfc52c /src
downloadrwebbrowser-44ad3c8b36540c6b0b3144a21ac40310e163bb19.tar.gz
rwebbrowser-44ad3c8b36540c6b0b3144a21ac40310e163bb19.tar.xz
feat: initialize project structure with CMake build system, C++23 support, and core browser scaffolding
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt11
-rw-r--r--src/core/browser.cc30
-rw-r--r--src/core/license.cc69
-rw-r--r--src/main.cc71
4 files changed, 181 insertions, 0 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 0000000..9ddc717
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,11 @@
+file(GLOB_RECURSE ALL_SOURCES CONFIGURE_DEPENDS "*.cc")
+
+set(MAIN_SRC "${CMAKE_CURRENT_SOURCE_DIR}/main.cc")
+list(REMOVE_ITEM ALL_SOURCES ${MAIN_SRC})
+
+add_library(ricochet_core STATIC ${ALL_SOURCES})
+target_include_directories(ricochet_core PUBLIC ${PROJECT_SOURCE_DIR}/include)
+
+add_executable(ricochet ${MAIN_SRC})
+target_link_libraries(ricochet PRIVATE ricochet_core)
+# target_link_libraries(ricochet PRIVATE ricochet_core curl ncurses) \ No newline at end of file
diff --git a/src/core/browser.cc b/src/core/browser.cc
new file mode 100644
index 0000000..88c47be
--- /dev/null
+++ b/src/core/browser.cc
@@ -0,0 +1,30 @@
+/*
+ * Ricochet - A minimalist CLI web browser for fast, distraction-free navigation.
+ * Copyright (C) 2026 Richard Qin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include "ricochet/core/browser.hh"
+#include <iostream>
+
+namespace ricochet::core {
+
+int Browser::run( std::string_view initial_url )
+{
+ std::cout << "Browser: Navigating to " << initial_url << "...\n";
+ return 0;
+}
+
+} // namespace ricochet::core
diff --git a/src/core/license.cc b/src/core/license.cc
new file mode 100644
index 0000000..587a942
--- /dev/null
+++ b/src/core/license.cc
@@ -0,0 +1,69 @@
+/*
+ * Ricochet - A minimalist CLI web browser for fast, distraction-free navigation.
+ * Copyright (C) 2026 Richard Qin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include "ricochet/core/license.hh"
+#include <iostream>
+
+namespace ricochet::core {
+
+void print_license_notice()
+{
+ std::cout << "Ricochet Copyright (C) 2026 Your Name\n"
+ << "Ricochet comes with ABSOLUTELY NO WARRANTY; for details type 'show w'.\n"
+ << "This is free software, and you are welcome to redistribute it\n"
+ << "under certain conditions; type 'show c' for details.\n\n";
+}
+
+void show_warranty()
+{
+ std::cout << R"(
+[ Ricochet - WARRANTY INFORMATION ]
+
+THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER
+PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
+EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+
+THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
+SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
+SERVICING, REPAIR OR CORRECTION.
+)" << '\n';
+}
+
+void show_copying()
+{
+ std::cout << R"(
+[ Ricochet - COPYING CONDITIONS ]
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <https://www.gnu.org/licenses/>.
+)" << '\n';
+}
+
+} // namespace ricochet::core \ No newline at end of file
diff --git a/src/main.cc b/src/main.cc
new file mode 100644
index 0000000..0371cda
--- /dev/null
+++ b/src/main.cc
@@ -0,0 +1,71 @@
+/*
+ * Ricochet - A minimalist CLI web browser for fast, distraction-free navigation.
+ * Copyright (C) 2026 Richard Qin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include <iostream>
+#include <span>
+#include <string_view>
+#include <vector>
+
+#include "ricochet/core/browser.hh"
+#include "ricochet/core/license.hh"
+
+namespace {
+
+void print_usage( std::string_view program_name )
+{
+ std::cout << "Usage: " << program_name << " [URL]\n"
+ << "Example: " << program_name << " https://wikipedia.org\n";
+}
+
+} // namespace
+
+int main( int argc, char* argv[] )
+{
+ const std::span<char*> args_view( argv, static_cast<size_t>( argc ) );
+ const std::vector<std::string_view> args( args_view.begin(), args_view.end() );
+
+ ricochet::core::print_license_notice();
+
+ if ( args.size() < 2 ) {
+ std::cerr << "Error: No URL provided.\n";
+ print_usage( args[0] );
+ return 1;
+ }
+
+ const std::string_view input = args[1];
+
+ if ( input == "show" ) {
+ if ( args[2] == "w" ) {
+ ricochet::core::show_warranty();
+ } else if ( args[2] == "c" ) {
+ ricochet::core::show_copying();
+ } else {
+ std::cerr << "Error: Invalid argument for show command.\n";
+ print_usage( args[0] );
+ return 1;
+ }
+ return 0;
+ }
+
+ try {
+ return ricochet::core::Browser::run( input );
+ } catch ( const std::exception& e ) {
+ std::cerr << "Critical Error: " << e.what() << "\n";
+ return 1;
+ }
+} \ No newline at end of file