mirror of
				https://github.com/ArthurSonzogni/FTXUI.git
				synced 2025-10-31 10:38:09 +08:00 
			
		
		
		
	Feature: hyperlink support. (#665)
				
					
				
			See the [OSC 8 page](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda). FTXUI support proposed by @aaleino in [#662](https://github.com/ArthurSonzogni/FTXUI/issues/662). API: ```cpp auto link = text("Click here") | hyperlink("https://github.com/FTXUI") ``` Fixed:https://github.com/ArthurSonzogni/FTXUI/issues/662
This commit is contained in:
		| @@ -109,6 +109,8 @@ Element bgcolor(const LinearGradient&, Element); | ||||
| Decorator focusPosition(int x, int y); | ||||
| Decorator focusPositionRelative(float x, float y); | ||||
| Element automerge(Element child); | ||||
| Decorator hyperlink(std::string link); | ||||
| Element hyperlink(std::string link, Element child); | ||||
|  | ||||
| // --- Layout is | ||||
| // Horizontal, Vertical or stacked set of elements. | ||||
|   | ||||
| @@ -1,8 +1,9 @@ | ||||
| #ifndef FTXUI_SCREEN_SCREEN_HPP | ||||
| #define FTXUI_SCREEN_SCREEN_HPP | ||||
|  | ||||
| #include <cstdint>  // for uint8_t | ||||
| #include <memory> | ||||
| #include <string>  // for string, allocator, basic_string | ||||
| #include <string>  // for string, basic_string, allocator | ||||
| #include <vector>  // for vector | ||||
|  | ||||
| #include "ftxui/screen/box.hpp"       // for Box | ||||
| @@ -20,6 +21,10 @@ struct Pixel { | ||||
|   // like: a⃦, this can potentially contains multiple codepoitns. | ||||
|   std::string character = " "; | ||||
|  | ||||
|   // The hyperlink associated with the pixel. | ||||
|   // 0 is the default value, meaning no hyperlink. | ||||
|   uint8_t hyperlink = 0; | ||||
|  | ||||
|   // Colors: | ||||
|   Color background_color = Color::Default; | ||||
|   Color foreground_color = Color::Default; | ||||
| @@ -99,6 +104,11 @@ class Screen { | ||||
|   Cursor cursor() const { return cursor_; } | ||||
|   void SetCursor(Cursor cursor) { cursor_ = cursor; } | ||||
|  | ||||
|   // Store an hyperlink in the screen. Return the id of the hyperlink. The id is | ||||
|   // used to identify the hyperlink when the user click on it. | ||||
|   uint8_t RegisterHyperlink(std::string link); | ||||
|   const std::string& Hyperlink(uint8_t id) const; | ||||
|  | ||||
|   Box stencil; | ||||
|  | ||||
|  protected: | ||||
| @@ -106,6 +116,7 @@ class Screen { | ||||
|   int dimy_; | ||||
|   std::vector<std::vector<Pixel>> pixels_; | ||||
|   Cursor cursor_; | ||||
|   std::vector<std::string> hyperlinks_ = {""}; | ||||
| }; | ||||
|  | ||||
| }  // namespace ftxui | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Arthur Sonzogni
					Arthur Sonzogni