foreseen

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

shared.cpp (2397B)


      1 #include "../include/shared.hpp"
      2 
      3 // =============================================================================
      4 // CLI OPTIONS
      5 // =============================================================================
      6 
      7 // These are the defaults for CLI options. When options are specified from the
      8 // CLI they will supersede these values.
      9 
     10 // When using the 'o' search menu, this will be infered as the base url of the
     11 // search.
     12 
     13 // TODO: Must this be url encoded?
     14 std::string DEFAULT_SEARCH_ENGINE = "gemini://tlgs.one/search";
     15 
     16 // This is the maximum number of links to prefetch per page.
     17 
     18 int SITE_CACHE_LIMIT = 10;
     19 
     20 // The prefetch cache and history cache may both have CACHE_SIZE sites within
     21 // their respective caches at any given time.
     22 
     23 // TODO: given this definition; check to make sure eviction happens prior to
     24 // insertion to maintain size invariant at all times.
     25 
     26 int CACHE_SIZE = 50;
     27 
     28 // =============================================================================
     29 // COLORS
     30 // =============================================================================
     31 
     32 // Colors vary by $TERM. See ncurses and terminfo docs for details. The default
     33 // constants assume a 256-color terminal.
     34 
     35 uint8_t COLOR_LINK = 159;
     36 uint8_t COLOR_PREFORMATTED = 201;
     37 uint8_t COLOR_QUOTE = 5;
     38 
     39 uint8_t COLOR_LIST_ITEM = 15;
     40 uint8_t COLOR_FORMAT_SWITCH = 7;
     41 uint8_t COLOR_PLAINTEXT = 15;
     42 
     43 uint8_t COLOR_H3 = 6;
     44 uint8_t COLOR_H2 = 2;
     45 uint8_t COLOR_H1 = 1;
     46 
     47 // =============================================================================
     48 // OTHER
     49 // =============================================================================
     50 
     51 // This limits the size of gemini protocol responses to at most
     52 // RESPONSE_SIZE_LIMIT_MB + 4kb, and at least RESPONSE_SIZE_LIMIT_MB.
     53 
     54 int RESPONSE_SIZE_LIMIT_MB = 5;
     55 
     56 // This specifies the base command to execute to handle unknown schemes (e.g.
     57 // http). The command will be executed along with the uri being followed as the
     58 // first positional argument.
     59 
     60 #ifdef DEBUG_MODE
     61 char openUnknownScheme[] = "echo";
     62 #else
     63 char openUnknownScheme[] = "xdg-open";
     64 #endif
     65 
     66 // This is the thread pool size for prefetching. Each thread is given at most
     67 // SITE_CACHE_LIMIT links to fetch when visiting a site. If all threads are in
     68 // use and a site is visited, prefetching is skipped.
     69 
     70 int THREAD_NUM = 4;
     71 
     72 // This is the maximum width text may be before it is forcibly wrapped.
     73 
     74 int MAX_WIDTH = 80;