mirror of
				https://github.com/ArthurSonzogni/FTXUI.git
				synced 2025-10-31 18:48:11 +08:00 
			
		
		
		
	Extract common struct Dimensions from Terminal (#171)
- Convert Dimension to namespace to allow defining Fit method from dom. - Use Dimensions extracted from Terminal as replacement struct. - Convert Terminal to namespace as it only defines static members. - Remove dom references from screen library (circular dependency).
This commit is contained in:
		 Tushar Maheshwari
					Tushar Maheshwari
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							34d955e9ac
						
					
				
				
					commit
					49e8cc57d3
				
			| @@ -8,6 +8,7 @@ | ||||
| #include "ftxui/screen/box.hpp" | ||||
| #include "ftxui/screen/color.hpp" | ||||
| #include "ftxui/screen/screen.hpp" | ||||
| #include "ftxui/screen/terminal.hpp" | ||||
|  | ||||
| namespace ftxui { | ||||
| class Node; | ||||
| @@ -102,6 +103,10 @@ Element nothing(Element element); | ||||
| // combinaison with dbox. | ||||
| Element clear_under(Element element); | ||||
|  | ||||
| namespace Dimension { | ||||
| Dimensions Fit(Element&); | ||||
| }  // namespace Dimension | ||||
|  | ||||
| }  // namespace ftxui | ||||
|  | ||||
| // Make container able to take any number of children as input. | ||||
|   | ||||
| @@ -7,10 +7,9 @@ | ||||
|  | ||||
| #include "ftxui/screen/box.hpp" | ||||
| #include "ftxui/screen/color.hpp" | ||||
| #include "ftxui/screen/terminal.hpp" | ||||
|  | ||||
| namespace ftxui { | ||||
| class Node; | ||||
| using Element = std::shared_ptr<Node>; | ||||
|  | ||||
| /// @brief A unicode character and its associated style. | ||||
| /// @ingroup screen | ||||
| @@ -41,14 +40,10 @@ struct Pixel { | ||||
|  | ||||
| /// @brief Define how the Screen's dimensions should look like. | ||||
| /// @ingroup screen | ||||
| struct Dimension { | ||||
|   static Dimension Fixed(int); | ||||
|   static Dimension Fit(Element&); | ||||
|   static Dimension Full(); | ||||
|  | ||||
|   int dimx; | ||||
|   int dimy; | ||||
| }; | ||||
| namespace Dimension { | ||||
| Dimensions Fixed(int); | ||||
| Dimensions Full(); | ||||
| }  // namespace Dimension | ||||
|  | ||||
| /// @brief A rectangular grid of Pixel. | ||||
| /// @ingroup screen | ||||
| @@ -56,8 +51,8 @@ class Screen { | ||||
|  public: | ||||
|   // Constructors: | ||||
|   Screen(int dimx, int dimy); | ||||
|   static Screen Create(Dimension dimension); | ||||
|   static Screen Create(Dimension width, Dimension height); | ||||
|   static Screen Create(Dimensions dimension); | ||||
|   static Screen Create(Dimensions width, Dimensions height); | ||||
|  | ||||
|   // Node write into the screen using Screen::at. | ||||
|   wchar_t& at(int x, int y); | ||||
|   | ||||
| @@ -2,24 +2,23 @@ | ||||
| #define FTXUI_CORE_TERMINAL_HPP | ||||
|  | ||||
| namespace ftxui { | ||||
|  | ||||
| class Terminal { | ||||
|  public: | ||||
|   struct Dimensions { | ||||
|     int dimx; | ||||
|     int dimy; | ||||
|   }; | ||||
|   static Dimensions Size(); | ||||
|  | ||||
|   enum Color { | ||||
|     Palette1, | ||||
|     Palette16, | ||||
|     Palette256, | ||||
|     TrueColor, | ||||
|   }; | ||||
|   static Color ColorSupport(); | ||||
| struct Dimensions { | ||||
|   int dimx; | ||||
|   int dimy; | ||||
| }; | ||||
|  | ||||
| namespace Terminal { | ||||
| Dimensions Size(); | ||||
|  | ||||
| enum Color { | ||||
|   Palette1, | ||||
|   Palette16, | ||||
|   Palette256, | ||||
|   TrueColor, | ||||
| }; | ||||
| Color ColorSupport(); | ||||
| }  // namespace Terminal | ||||
|  | ||||
| }  // namespace ftxui | ||||
|  | ||||
| #endif /* end of include guard: FTXUI_CORE_TERMINAL_HPP */ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user