mirror of
				https://github.com/ArthurSonzogni/FTXUI.git
				synced 2025-10-31 18:48:11 +08:00 
			
		
		
		
	| @@ -1,26 +1,23 @@ | ||||
| #include <functional>  // for function | ||||
| #include <iostream>  // for basic_ostream::operator<<, operator<<, endl, basic_ostream, basic_ostream<>::__ostream_type, cout, ostream | ||||
| #include <string>    // for string, basic_string, allocator | ||||
| #include <vector>    // for vector | ||||
| #include <string>  // for basic_string, string, allocator | ||||
| #include <vector>  // for vector | ||||
|  | ||||
| #include "ftxui/component/captured_mouse.hpp"      // for ftxui | ||||
| #include "ftxui/component/component.hpp"           // for Menu | ||||
| #include "ftxui/component/component_options.hpp"   // for MenuOption | ||||
| #include "ftxui/component/captured_mouse.hpp"  // for ftxui | ||||
| #include "ftxui/component/component.hpp"  // for Dropdown, Horizontal, Vertical | ||||
| #include "ftxui/component/screen_interactive.hpp"  // for ScreenInteractive | ||||
|  | ||||
| int main(int argc, const char* argv[]) { | ||||
|   using namespace ftxui; | ||||
|  | ||||
|   std::vector<std::string> entries = { | ||||
|       "tribute",     "clearance", "ally",     "bend",  "electronics", | ||||
|       "module",      "era",       "cultural", "sniff", "nationalism", | ||||
|       "negotiation", "deliver",   "figure",   "east", | ||||
|       "tribute",     "clearance", "ally",     "bend",  "electronics", | ||||
|       "module",      "era",       "cultural", "sniff", "nationalism", | ||||
|       "negotiation", "deliver",   "figure",   "east", | ||||
|       "tribute",     "clearance", "ally",     "bend",  "electronics", | ||||
|       "module",      "era",       "cultural", "sniff", "nationalism", | ||||
|       "negotiation", "deliver",   "figure",   "east", | ||||
|       "tribute",     "clearance", "ally",        "bend",        "electronics", | ||||
|       "module",      "era",       "cultural",    "sniff",       "nationalism", | ||||
|       "negotiation", "deliver",   "figure",      "east",        "tribute", | ||||
|       "clearance",   "ally",      "bend",        "electronics", "module", | ||||
|       "era",         "cultural",  "sniff",       "nationalism", "negotiation", | ||||
|       "deliver",     "figure",    "east",        "tribute",     "clearance", | ||||
|       "ally",        "bend",      "electronics", "module",      "era", | ||||
|       "cultural",    "sniff",     "nationalism", "negotiation", "deliver", | ||||
|       "figure",      "east", | ||||
|   }; | ||||
|  | ||||
|   int selected_1 = 0; | ||||
|   | ||||
| @@ -1,12 +1,12 @@ | ||||
| #include <functional>  // for function | ||||
| #include <iostream>  // for basic_ostream::operator<<, operator<<, endl, basic_ostream, basic_ostream<>::__ostream_type, cout, ostream | ||||
| #include <string>    // for string, basic_string, allocator | ||||
| #include <vector>    // for vector | ||||
| #include <memory>  // for shared_ptr, __shared_ptr_access | ||||
| #include <string>  // for string, basic_string, allocator | ||||
| #include <vector>  // for vector | ||||
|  | ||||
| #include "ftxui/component/captured_mouse.hpp"      // for ftxui | ||||
| #include "ftxui/component/component.hpp"           // for Menu | ||||
| #include "ftxui/component/component_options.hpp"   // for MenuOption | ||||
| #include "ftxui/component/screen_interactive.hpp"  // for ScreenInteractive | ||||
| #include "ftxui/component/captured_mouse.hpp"  // for ftxui | ||||
| #include "ftxui/component/component.hpp"  // for Checkbox, Maybe, Radiobox, Renderer, Vertical | ||||
| #include "ftxui/component/component_base.hpp"  // for ComponentBase | ||||
| #include "ftxui/component/screen_interactive.hpp"  // for Component, ScreenInteractive | ||||
| #include "ftxui/dom/elements.hpp"  // for Element, operator|, border | ||||
|  | ||||
| using namespace ftxui; | ||||
| Component Border(Component child) { | ||||
| @@ -14,7 +14,6 @@ Component Border(Component child) { | ||||
| } | ||||
|  | ||||
| int main(int argc, const char* argv[]) { | ||||
|  | ||||
|   std::vector<std::string> entries = { | ||||
|       "entry 1", | ||||
|       "entry 2", | ||||
|   | ||||
| @@ -3,9 +3,13 @@ set(DIRECTORY_LIB dom) | ||||
| example(border) | ||||
| example(border_style) | ||||
| example(color_gallery) | ||||
| example(color_info_palette256) | ||||
| example(color_truecolor_HSV) | ||||
| example(color_truecolor_RGB) | ||||
| example(dbox) | ||||
| example(gauge) | ||||
| example(graph) | ||||
| example(gridbox) | ||||
| example(hflow) | ||||
| example(html_like) | ||||
| example(package_manager) | ||||
| @@ -17,13 +21,10 @@ example(spinner) | ||||
| example(style_blink) | ||||
| example(style_bold) | ||||
| example(style_color) | ||||
| example(color_truecolor_RGB) | ||||
| example(color_truecolor_HSV) | ||||
| example(color_info_palette256) | ||||
| example(style_dim) | ||||
| example(gridbox) | ||||
| example(style_gallery) | ||||
| example(style_inverted) | ||||
| example(style_underlined) | ||||
| example(table) | ||||
| example(vbox_hbox) | ||||
| example(window) | ||||
|   | ||||
							
								
								
									
										66
									
								
								examples/dom/table.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								examples/dom/table.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,66 @@ | ||||
| #include <ftxui/dom/elements.hpp>  // for color, Fit, LIGHT, align_right, bold, DOUBLE | ||||
| #include <ftxui/dom/table.hpp>      // for Table, TableSelection | ||||
| #include <ftxui/screen/screen.hpp>  // for Screen | ||||
| #include <iostream>                 // for endl, cout, ostream | ||||
| #include <string>                   // for basic_string, allocator, string | ||||
| #include <vector>                   // for vector | ||||
|  | ||||
| #include "ftxui/dom/node.hpp"    // for Render | ||||
| #include "ftxui/screen/box.hpp"  // for ftxui | ||||
| #include "ftxui/screen/color.hpp"  // for Color, Color::Blue, Color::Cyan, Color::White | ||||
|  | ||||
| int main(int argc, const char* argv[]) { | ||||
|   using namespace ftxui; | ||||
|  | ||||
|   auto table = Table({ | ||||
|       {"Version", "Marketing name", "Release date", "API level", "Runtime"}, | ||||
|       {"2.3", "Gingerbread", "February 9 2011", "10", "Dalvik 1.4.0"}, | ||||
|       {"4.0", "Ice Cream Sandwich", "October 19 2011", "15", "Dalvik"}, | ||||
|       {"4.1", "Jelly Bean", "July 9 2012", "16", "Dalvik"}, | ||||
|       {"4.2", "Jelly Bean", "November 13 2012", "17", "Dalvik"}, | ||||
|       {"4.3", "Jelly Bean", "July 24 2013", "18", "Dalvik"}, | ||||
|       {"4.4", "KitKat", "October 31 2013", "19", "Dalvik and ART"}, | ||||
|       {"5.0", "Lollipop", "November 3 2014", "21", "ART"}, | ||||
|       {"5.1", "Lollipop", "March 9 2015", "22", "ART"}, | ||||
|       {"6.0", "Marshmallow", "October 5 2015", "23", "ART"}, | ||||
|       {"7.0", "Nougat", "August 22 2016", "24", "ART"}, | ||||
|       {"7.1", "Nougat", "October 4 2016", "25", "ART"}, | ||||
|       {"8.0", "Oreo", "August 21 2017", "26", "ART"}, | ||||
|       {"8.1", "Oreo", "December 5 2017", "27", "ART"}, | ||||
|       {"9", "Pie", "August 6 2018", "28", "ART"}, | ||||
|       {"10", "10", "September 3 2019", "29", "ART"}, | ||||
|       {"11", "11", "September 8 2020", "30", "ART"}, | ||||
|   }); | ||||
|  | ||||
|   table.SelectAll().Border(LIGHT); | ||||
|  | ||||
|   // Add border around the first column. | ||||
|   table.SelectColumn(0).Border(LIGHT); | ||||
|  | ||||
|   // Make first row bold with a double border. | ||||
|   table.SelectRow(0).Decorate(bold); | ||||
|   table.SelectRow(0).SeparatorVertical(LIGHT); | ||||
|   table.SelectRow(0).Border(DOUBLE); | ||||
|  | ||||
|   // Align right the "Release date" column. | ||||
|   table.SelectColumn(2).DecorateCells(align_right); | ||||
|  | ||||
|   // Select row from the second to the last. | ||||
|   auto content = table.SelectRows(1, -1); | ||||
|   // Alternate in between 3 colors. | ||||
|   content.DecorateCellsAlternateRow(color(Color::Blue), 3, 0); | ||||
|   content.DecorateCellsAlternateRow(color(Color::Cyan), 3, 1); | ||||
|   content.DecorateCellsAlternateRow(color(Color::White), 3, 2); | ||||
|  | ||||
|   auto document = table.Render(); | ||||
|   auto screen = Screen::Create(Dimension::Fit(document)); | ||||
|   Render(screen, document); | ||||
|   screen.Print(); | ||||
|   std::cout << std::endl; | ||||
|  | ||||
|   return 0; | ||||
| } | ||||
|  | ||||
| // Copyright 2020 Arthur Sonzogni. All rights reserved. | ||||
| // Use of this source code is governed by the MIT license that can be found in | ||||
| // the LICENSE file. | ||||
		Reference in New Issue
	
	Block a user
	 Arthur Sonzogni
					Arthur Sonzogni