mirror of
https://github.com/m1ngsama/TUT.git
synced 2025-12-24 10:51:46 +00:00
Major improvements to link handling and navigation: Features: - Display links inline with numbered indicators [0], [1], etc. - Quick navigation: type number + Enter to jump to link - Fast follow: press 'f' + number to open link directly - Visual improvements: links shown with underline and highlight - Remove separate link list at bottom for better readability Technical changes: - Add InlineLink structure to track link positions in text - Implement wrap_text_with_links() for intelligent text wrapping - Add GOTO_LINK and FOLLOW_LINK_NUM actions - Implement LINK input mode for 'f' command - Character-by-character rendering for proper link highlighting - Update help documentation with new navigation methods Usage examples: - 3<Enter> : Jump to link 3 - f5 or 5f : Open link 5 directly - Tab/Enter : Traditional navigation still works All comments converted to standard Unix style (English).
53 lines
1.1 KiB
C++
53 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include "html_parser.h"
|
|
#include <string>
|
|
#include <vector>
|
|
#include <memory>
|
|
#include <curses.h>
|
|
|
|
struct RenderedLine {
|
|
std::string text;
|
|
int color_pair;
|
|
bool is_bold;
|
|
bool is_link;
|
|
int link_index;
|
|
std::vector<std::pair<size_t, size_t>> link_ranges; // (start, end) positions of links in this line
|
|
};
|
|
|
|
struct RenderConfig {
|
|
int max_width = 80;
|
|
int margin_left = 0;
|
|
bool center_content = true;
|
|
int paragraph_spacing = 1;
|
|
bool show_link_indicators = false; // Set to false to show inline links by default
|
|
};
|
|
|
|
class TextRenderer {
|
|
public:
|
|
TextRenderer();
|
|
~TextRenderer();
|
|
|
|
std::vector<RenderedLine> render(const ParsedDocument& doc, int screen_width);
|
|
void set_config(const RenderConfig& config);
|
|
RenderConfig get_config() const;
|
|
|
|
private:
|
|
class Impl;
|
|
std::unique_ptr<Impl> pImpl;
|
|
};
|
|
|
|
enum ColorScheme {
|
|
COLOR_NORMAL = 1,
|
|
COLOR_HEADING1,
|
|
COLOR_HEADING2,
|
|
COLOR_HEADING3,
|
|
COLOR_LINK,
|
|
COLOR_LINK_ACTIVE,
|
|
COLOR_STATUS_BAR,
|
|
COLOR_URL_BAR,
|
|
COLOR_SEARCH_HIGHLIGHT,
|
|
COLOR_DIM
|
|
};
|
|
|
|
void init_color_scheme();
|