Nimbin[12]?SDL & Graphics / sdl_runtime_compiler / src/text/text.hpp

sdl_runtime_compiler git · main

SDL3 game for running and compiling code at runtime

sdl3 c++ compiler dlopen cmake · first commit 2026-04-19 · last commit 2026-07-03 (3 months ago) · synced 3 days ago · upstream: git.ide3.de/hsnr/sdl-runtime-compiler

C++ 72.3% C 26.2%
git clone https://git.christianimmanuel.de/sdl-graphics/sdl_runtime_compiler.gitwget https://git.christianimmanuel.de/sdl-graphics/sdl_runtime_compiler/archive/sdl_runtime_compiler.tar.gz
src/text/text.hpp 1.7 KB · 95 lines raw
#pragma once

#include <string>

#include "utils/globals.hpp"

namespace
Nimbin
{

namespace
Text
{
    class  Handler;
    struct Line;
    struct HiSpan;

    namespace Token {
        struct Ai;
        struct Data;
        struct Description;
        enum class Type : uint8_t;
    }


    enum class ColorSource : uint8_t { Lexed, Lint, Static };
    enum class FaceMode    : uint8_t { None, Yaw, Pitch, Both };
    enum class LayoutMode  : uint8_t { Display, Editing, FaceCamera };


    DynArray<std::string>
        wrap_String(const std::string& text, size_t max_chars);

    std::string
        ascii_Sanitize(const std::string& in);

} // namespace Text


namespace
Text
{

    struct HiSpan
    {
        size_t byte_begin;
        size_t byte_end;
        Text::Token::Type
               type;
    };


    namespace CppHighlight
    {
        DynArray<HiSpan>  classify     (const std::string& source);
        Text::Token::Type classify_Word(const std::string& word);
    }

} // namespace Text


namespace
Text
{

    struct Line
    {
        DynArray<TokenPtr> tokens;

        double bounce_off   { 0.0 };
        double bounce_vel   { 0.0 };
        double y            { 0.0 };
        double line_height  { 0.0 };
        double word_spacing { 0.0 };

        TokenPtr num_left;
        TokenPtr num_right;

        int  number      { -1 };
        bool show_number { false };

        bool   is_Empty() const { return tokens.empty(); }
        size_t count   () const { return tokens.size(); }

        double width   (double gap) const;

        Token::Data* token_At_Byte(size_t off) const;

        void clear();
    };


} // namespace Text

} // namespace Nimbin