├── .github └── FUNDING.yml ├── .gitignore ├── src ├── main.cpp ├── home.html ├── oserr_exception.cpp ├── root_control.cpp ├── config.h.in ├── cmake │ └── text_to_rez.cmake ├── helpers.cpp ├── about_window.cpp ├── browser_control.cpp ├── user_control.cpp ├── browser_document.cpp ├── quickdraw_font.cpp ├── machine.cpp ├── browser_window.cpp ├── CMakeLists.txt ├── quickdraw_container.cpp ├── base_control.cpp ├── base_window.cpp ├── browser_app.cpp ├── hellolite.r └── base_app.cpp ├── .pre-commit-config.yaml ├── .gitmodules ├── .reuse └── dep5 ├── make_and_run.sh ├── include ├── root_control.h ├── oserr_exception.h ├── machine.h ├── helpers.h ├── about_window.h ├── user_control.h ├── browser_document.h ├── browser_app.h ├── quickdraw_font.h ├── browser_control.h ├── browser_window.h ├── base_control.h ├── ResourceConstants.h ├── base_window.h ├── quickdraw_container.h └── base_app.h ├── run.sh ├── third_party ├── dlmalloc │ ├── CMakeLists.txt │ ├── macos-dlmalloc.c │ └── malloc.h └── CMakeLists.txt ├── LICENSES ├── MIT.txt └── CC0-1.0.txt ├── CMakeLists.txt └── make.sh /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: © 2022 Ryan C Schmidt 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | github: [ryandesign] 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: © 2022 Ryan C Schmidt 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | *.html 6 | *.orig 7 | *.patch 8 | .vscode 9 | build 10 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: © 2022 Ryan C Schmidt 2 | // 3 | // SPDX-License-Identifier: MIT 4 | 5 | #include "browser_app.h" 6 | 7 | int main() 8 | { 9 | browser_app().run(); 10 | } 11 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: © 2022 Ryan C Schmidt 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | repos: 6 | - repo: https://github.com/fsfe/reuse-tool 7 | rev: v1.0.0 8 | hooks: 9 | - id: reuse 10 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: © 2022 Ryan C Schmidt 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | [submodule "third_party/litehtml"] 6 | path = third_party/litehtml 7 | url = https://github.com/litehtml/litehtml.git 8 | branch = master 9 | -------------------------------------------------------------------------------- /.reuse/dep5: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: © 2022 Ryan C Schmidt 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 6 | Upstream-Name: 7 | Upstream-Contact: Ryan C Schmidt 8 | Source: 9 | -------------------------------------------------------------------------------- /make_and_run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # SPDX-FileCopyrightText: © 2022 Ryan C Schmidt 4 | # 5 | # SPDX-License-Identifier: MIT 6 | 7 | set -euo pipefail 8 | 9 | if [[ ${BASH_SOURCE[0]} = */* ]]; then 10 | cd -- "${BASH_SOURCE%/*}/" || exit 11 | fi 12 | 13 | ./make.sh "$@" && ./run.sh "$@" 14 | -------------------------------------------------------------------------------- /src/home.html: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | Hello World 10 | 11 | 12 |

The quick brown fox jumps over the lazy dog.

13 | 14 | 15 | -------------------------------------------------------------------------------- /src/oserr_exception.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: © 2022 Ryan C Schmidt 2 | // 3 | // SPDX-License-Identifier: MIT 4 | 5 | #include "oserr_exception.h" 6 | 7 | oserr_exception::oserr_exception(OSErr err) 8 | : m_err(err) 9 | { 10 | } 11 | 12 | oserr_exception::~oserr_exception() 13 | { 14 | } 15 | 16 | OSErr oserr_exception::err() const 17 | { 18 | return m_err; 19 | } 20 | -------------------------------------------------------------------------------- /include/root_control.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: © 2022 Ryan C Schmidt 2 | // 3 | // SPDX-License-Identifier: MIT 4 | 5 | #ifndef ROOT_CONTROL_H 6 | #define ROOT_CONTROL_H 7 | 8 | #include "base_control.h" 9 | 10 | class root_control final : public base_control 11 | { 12 | public: 13 | root_control(WindowRecord& window); 14 | ~root_control(); 15 | }; 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /src/root_control.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: © 2022 Ryan C Schmidt 2 | // 3 | // SPDX-License-Identifier: MIT 4 | 5 | #include "root_control.h" 6 | 7 | #include 8 | 9 | root_control::root_control(WindowRecord& window) : base_control() 10 | { 11 | OSErr err = CreateRootControl(reinterpret_cast(&window), &m_control); 12 | if (noErr != err) 13 | throw std::bad_alloc(); 14 | init(); 15 | } 16 | 17 | root_control::~root_control() 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /include/oserr_exception.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: © 2022 Ryan C Schmidt 2 | // 3 | // SPDX-License-Identifier: MIT 4 | 5 | #ifndef OSERR_EXCEPTION_H 6 | #define OSERR_EXCEPTION_H 7 | 8 | #include 9 | #include 10 | 11 | class oserr_exception : public std::exception 12 | { 13 | public: 14 | oserr_exception(OSErr err); 15 | ~oserr_exception(); 16 | OSErr err() const; 17 | 18 | protected: 19 | OSErr m_err; 20 | }; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /src/config.h.in: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: © 2022 Ryan C Schmidt 2 | // 3 | // SPDX-License-Identifier: MIT 4 | 5 | #ifndef CONFIG_H 6 | #define CONFIG_H 7 | 8 | #define k_app_version_string "@PROJECT_VERSION@" 9 | #define k_app_version_major @PROJECT_VERSION_MAJOR@ 10 | #define k_app_version_minor @PROJECT_VERSION_MINOR@ 11 | #define k_app_version_patch @PROJECT_VERSION_PATCH@ 12 | #define k_app_development_stage @PROJECT_DEVELOPMENT_STAGE@ 13 | #define k_app_prerelease_revision @PROJECT_VERSION_TWEAK@ 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /include/machine.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: © 2022 Ryan C Schmidt 2 | // 3 | // SPDX-License-Identifier: MIT 4 | 5 | #ifndef MACHINE_H 6 | #define MACHINE_H 7 | 8 | #include 9 | #include 10 | 11 | namespace machine 12 | { 13 | bool has_128k_rom(); 14 | bool has_gestalt(); 15 | int16_t get_system_version(); 16 | bool has_appearance(); 17 | bool trap_available(uint16_t trap); 18 | TrapType get_trap_type(uint16_t trap); 19 | int16_t get_num_toolbox_traps(); 20 | } 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /include/helpers.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: © 2022 Ryan C Schmidt 2 | // 3 | // SPDX-License-Identifier: MIT 4 | 5 | #ifndef HELPERS_H 6 | #define HELPERS_H 7 | 8 | #include 9 | #include 10 | 11 | bool is_desk_accessory_window(WindowPtr window); 12 | bool is_desk_accessory_window(WindowRecord const& window); 13 | int16_t rect_height(Rect const& rect); 14 | int16_t rect_width(Rect const& rect); 15 | std::string& pappend(std::string& dst, ConstStr255Param src); 16 | void debugprintf(char const *format, ...); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /include/about_window.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: © 2022 Ryan C Schmidt 2 | // 3 | // SPDX-License-Identifier: MIT 4 | 5 | #ifndef ABOUT_WINDOW_H 6 | #define ABOUT_WINDOW_H 7 | 8 | #include "base_control.h" 9 | #include "base_window.h" 10 | #include "root_control.h" 11 | 12 | class about_window : public base_window 13 | { 14 | public: 15 | about_window(); 16 | ~about_window(); 17 | void close() override; 18 | 19 | private: 20 | root_control m_root_control; 21 | base_control m_text; 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /include/user_control.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: © 2022 Ryan C Schmidt 2 | // 3 | // SPDX-License-Identifier: MIT 4 | 5 | #ifndef USER_CONTROL_H 6 | #define USER_CONTROL_H 7 | 8 | #include "base_control.h" 9 | 10 | class user_control : public base_control 11 | { 12 | public: 13 | user_control(int16_t resource_id, WindowRecord& window); 14 | ~user_control(); 15 | 16 | private: 17 | static pascal void draw_proc(ControlHandle control, int16_t part); 18 | virtual void draw(int16_t part) const; 19 | static pascal void activate_proc(ControlHandle control, Boolean activating); 20 | virtual void activate(bool activating); 21 | }; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /include/browser_document.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: © 2022 Ryan C Schmidt 2 | // 3 | // SPDX-License-Identifier: MIT 4 | 5 | #ifndef BROWSER_DOCUMENT_H 6 | #define BROWSER_DOCUMENT_H 7 | 8 | #include 9 | #ifdef USE_LITEHTML 10 | #include 11 | #endif 12 | #include 13 | 14 | #include "browser_control.h" 15 | 16 | class browser_document 17 | { 18 | public: 19 | typedef std::shared_ptr ptr; 20 | 21 | browser_document(); 22 | ~browser_document(); 23 | void set_html(const char *const html, browser_control& control); 24 | void render_if_needed(int width); 25 | void draw(Rect const& rect); 26 | Point get_dimensions(); 27 | 28 | private: 29 | #ifdef USE_LITEHTML 30 | litehtml::document::ptr m_lite_document; 31 | int16_t m_rendered_width; 32 | #endif 33 | Point m_scroll; 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # SPDX-FileCopyrightText: © 2022 Ryan C Schmidt 4 | # 5 | # SPDX-License-Identifier: MIT 6 | 7 | set -euo pipefail 8 | 9 | if [[ ${BASH_SOURCE[0]} = */* ]]; then 10 | cd -- "${BASH_SOURCE%/*}/" || exit 11 | fi 12 | 13 | : "${RETRO68:=/opt/local/libexec/Retro68}" 14 | : "${CMAKE_BUILD_TYPE:=RelWithDebInfo}" 15 | : "${BUILD_DIR:=build}" 16 | : "${BUILD_TYPE_DIR:="$BUILD_DIR/$CMAKE_BUILD_TYPE"}" 17 | 18 | arch=fat 19 | while (($# > 0)); do 20 | case $1 in 21 | 68k|fat|ppc) 22 | arch="$1" 23 | ;; 24 | *) 25 | printf 'unknown option %s\n' "$1" >&2 26 | exit 1 27 | esac 28 | shift 29 | done 30 | 31 | set -x 32 | 33 | build_dir_68k="$BUILD_TYPE_DIR/m68k" 34 | build_dir_ppc="$BUILD_TYPE_DIR/powerpc" 35 | build_dir_fat="$BUILD_TYPE_DIR/fat" 36 | 37 | build_dir_var="build_dir_$arch" 38 | 39 | "$RETRO68"/bin/LaunchAPPL "${!build_dir_var}"/src/app.bin 40 | -------------------------------------------------------------------------------- /include/browser_app.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: © 2022 Ryan C Schmidt 2 | // 3 | // SPDX-License-Identifier: MIT 4 | 5 | #ifndef BROWSER_APP_H 6 | #define BROWSER_APP_H 7 | 8 | #include "base_app.h" 9 | 10 | class browser_app : public base_app 11 | { 12 | public: 13 | browser_app(); 14 | ~browser_app() override; 15 | 16 | void fatal_error_alert(int16_t error_number); 17 | void error_alert(int16_t error_number); 18 | // void oserr_alert(OSErr err); 19 | void on_file_menu(int16_t menu_item); 20 | void on_edit_menu(int16_t menu_item); 21 | void on_window_menu(int16_t menu_item); 22 | void on_quit(); 23 | 24 | protected: 25 | void try_consume_event() override; 26 | void adjust_menu_bar() override; 27 | void adjust_menu_items() override; 28 | void on_menu(int16_t menu_id, int16_t menu_item) override; 29 | 30 | private: 31 | void about() override; 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /include/quickdraw_font.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: © 2022 Ryan C Schmidt 2 | // 3 | // SPDX-License-Identifier: MIT 4 | 5 | #ifndef QUICKDRAW_FONT_H 6 | #define QUICKDRAW_FONT_H 7 | 8 | // Mac headers 9 | #include 10 | #include 11 | 12 | // System headers 13 | 14 | // Third-party headers 15 | #include 16 | 17 | // My headers 18 | 19 | class quickdraw_font 20 | { 21 | public: 22 | quickdraw_font(const char *name, int16_t size, StyleParameter style = normal); 23 | quickdraw_font(int16_t id, int16_t size, StyleParameter style = normal); 24 | ~quickdraw_font(); 25 | void draw(const char *text, const litehtml::position& pos); 26 | int16_t width(const char *text); 27 | FontInfo& metrics(); 28 | 29 | private: 30 | int16_t m_id; 31 | int16_t m_size; 32 | StyleParameter m_style; 33 | FontInfo m_metrics; 34 | GrafPort m_port; 35 | 36 | void construct(); 37 | void set_port_font(); 38 | }; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /third_party/dlmalloc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: © 2022 Ryan C Schmidt 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | # Using dlmalloc avoids severe performance problems when using Retro68's default 6 | # NewPtr-based malloc implementation. 7 | # https://github.com/autc04/Retro68/issues/185 8 | add_library(dlmalloc OBJECT macos-dlmalloc.c) 9 | 10 | set(dlmalloc_LIBRARY "$" 11 | CACHE FILEPATH "dlmalloc library" 12 | ) 13 | 14 | set(functions 15 | bulk_free calloc free independent_calloc independent_comalloc mallinfo 16 | malloc malloc_footprint malloc_footprint_limit malloc_inspect_all 17 | malloc_max_footprint malloc_set_footprint_limit malloc_stats malloc_trim 18 | malloc_usable_size mallopt memalign posix_memalign pvalloc realloc 19 | realloc_in_place valloc 20 | ) 21 | list(TRANSFORM functions PREPEND "--wrap," OUTPUT_VARIABLE link_flags) 22 | list(PREPEND link_flags "-Wl") 23 | list(JOIN link_flags "," link_flags) 24 | set(dlmalloc_LINK_FLAGS "${link_flags}" 25 | CACHE STRING "dlmalloc link flags" 26 | ) 27 | -------------------------------------------------------------------------------- /include/browser_control.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: © 2022 Ryan C Schmidt 2 | // 3 | // SPDX-License-Identifier: MIT 4 | 5 | #ifndef BROWSER_CONTROL_H 6 | #define BROWSER_CONTROL_H 7 | 8 | #include 9 | 10 | #ifdef USE_LITEHTML 11 | #include "quickdraw_container.h" 12 | #endif 13 | #include "user_control.h" 14 | 15 | class browser_document; 16 | 17 | class browser_control : 18 | #ifdef USE_LITEHTML 19 | public quickdraw_container, 20 | #endif 21 | public user_control 22 | { 23 | public: 24 | browser_control(int16_t resource_id, WindowRecord& window); 25 | ~browser_control(); 26 | void set_document(std::shared_ptr document); 27 | 28 | #ifdef USE_LITEHTML 29 | // quickdraw_container overrides: 30 | void get_client_rect(litehtml::position& client) const override; 31 | void set_caption(char const *caption) override; 32 | #endif 33 | 34 | // user_control overrides: 35 | virtual void draw(int16_t part) const override; 36 | 37 | private: 38 | std::shared_ptr m_document; 39 | }; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /LICENSES/MIT.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to 7 | deal in the Software without restriction, including without limitation the 8 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9 | sell copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 | IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/cmake/text_to_rez.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: © 2022 Ryan C Schmidt 2 | # 3 | # SPDX-License-Identifier: MIT 4 | 5 | file(READ ${infile} data) 6 | set(result 0) 7 | while(NOT ${result} EQUAL -1) 8 | string(FIND "${data}" "" result) 11 | if(NOT ${result} EQUAL -1) 12 | string(REGEX REPLACE "-->(.*)" "<><>\\1" data "${data}") 13 | string(REGEX REPLACE "