foreseen

A text-based gemini browser with prefetching
git clone git://git.laack.co/foreseen.git
Log | Files | Refs | README | LICENSE

link.hpp (735B)


      1 #pragma once
      2 
      3 #include <cstdint>
      4 #include <optional>
      5 #include <string>
      6 
      7 #include "../vendor/uri.hpp"
      8 #include "line.hpp"
      9 
     10 class Link : public Line {
     11    private:
     12     bool invalid = false;
     13     int linkNumber = -1;
     14     std::string renderedText;
     15     uri linkDestination = uri("gemini://example.com");
     16     std::optional<std::string> linkText;
     17     uri parseDestination(std::string destination, std::optional<uri> prior);
     18 
     19    public:
     20     Link(std::string text, std::optional<uri> prior = std::nullopt,
     21          int linkNumber = -1);
     22     uri getLinkDestination();
     23     std::optional<std::string> getLinkText();
     24     std::string textToDraw() override;
     25     uint8_t getColor() override;
     26     bool isBold() override;
     27     LineType type() override;
     28 };