mirror of
				https://github.com/ArthurSonzogni/FTXUI.git
				synced 2025-11-04 05:28:15 +08:00 
			
		
		
		
	Fix format. Try compile on Windows.
This commit is contained in:
		@@ -1,4 +1,5 @@
 | 
			
		||||
#include "ftxui/component/checkbox.hpp"
 | 
			
		||||
 | 
			
		||||
#include <functional>
 | 
			
		||||
 | 
			
		||||
namespace ftxui {
 | 
			
		||||
@@ -17,7 +18,7 @@ bool CheckBox::OnEvent(Event event) {
 | 
			
		||||
    on_change();
 | 
			
		||||
    return true;
 | 
			
		||||
  }
 | 
			
		||||
  return false;  
 | 
			
		||||
  return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
}  // namespace ftxui
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,16 @@
 | 
			
		||||
#include "ftxui/component/component.hpp"
 | 
			
		||||
 | 
			
		||||
#include <assert.h>
 | 
			
		||||
 | 
			
		||||
#include <algorithm>
 | 
			
		||||
 | 
			
		||||
namespace ftxui {
 | 
			
		||||
void Component::Detach() { if (!parent_) return; auto it = std::find(std::begin(parent_->children_),
 | 
			
		||||
void Component::Detach() {
 | 
			
		||||
  if (!parent_)
 | 
			
		||||
    return;
 | 
			
		||||
  auto it = std::find(std::begin(parent_->children_),
 | 
			
		||||
                      std::end(parent_->children_), this);
 | 
			
		||||
  parent_->children_.erase(it);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Component::Attach(Component* parent) {
 | 
			
		||||
@@ -23,7 +28,7 @@ Component::~Component() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool Component::OnEvent(Event event) {
 | 
			
		||||
  for(Component* child : children_) {
 | 
			
		||||
  for (Component* child : children_) {
 | 
			
		||||
    if (child->OnEvent(event))
 | 
			
		||||
      return true;
 | 
			
		||||
  }
 | 
			
		||||
@@ -43,7 +48,7 @@ Element Component::Render() {
 | 
			
		||||
 | 
			
		||||
bool Component::Focused() {
 | 
			
		||||
  Component* current = this;
 | 
			
		||||
  for(;;) {
 | 
			
		||||
  for (;;) {
 | 
			
		||||
    Component* parent = current->parent_;
 | 
			
		||||
    if (!parent)
 | 
			
		||||
      return true;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,7 @@
 | 
			
		||||
#include "ftxui/component/container.hpp"
 | 
			
		||||
 | 
			
		||||
#include <algorithm>
 | 
			
		||||
 | 
			
		||||
namespace ftxui {
 | 
			
		||||
 | 
			
		||||
// static
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,7 @@
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include "ftxui/component/event.hpp"
 | 
			
		||||
 | 
			
		||||
#include <iostream>
 | 
			
		||||
 | 
			
		||||
#include "ftxui/screen/string.hpp"
 | 
			
		||||
 | 
			
		||||
namespace ftxui {
 | 
			
		||||
@@ -49,7 +51,7 @@ Event ParseCSI(std::function<char()> getchar, std::string& input) {
 | 
			
		||||
    char c = getchar();
 | 
			
		||||
    input += c;
 | 
			
		||||
 | 
			
		||||
    if (c >= '0' && c<= '9')
 | 
			
		||||
    if (c >= '0' && c <= '9')
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    if (c == ';')
 | 
			
		||||
@@ -93,9 +95,12 @@ Event ParseOSC(std::function<char()> getchar, std::string& input) {
 | 
			
		||||
Event ParseESC(std::function<char()> getchar, std::string& input) {
 | 
			
		||||
  input += getchar();
 | 
			
		||||
  switch (input.back()) {
 | 
			
		||||
    case 'P': return ParseDCS(getchar, input);
 | 
			
		||||
    case '[': return ParseCSI(getchar, input);
 | 
			
		||||
    case ']': return ParseOSC(getchar, input);
 | 
			
		||||
    case 'P':
 | 
			
		||||
      return ParseDCS(getchar, input);
 | 
			
		||||
    case '[':
 | 
			
		||||
      return ParseCSI(getchar, input);
 | 
			
		||||
    case ']':
 | 
			
		||||
      return ParseOSC(getchar, input);
 | 
			
		||||
    default:
 | 
			
		||||
      input += getchar();
 | 
			
		||||
      return Event::Special(input);
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
#include "ftxui/component/input.hpp"
 | 
			
		||||
#include "ftxui/screen/string.hpp"
 | 
			
		||||
#include <algorithm>
 | 
			
		||||
 | 
			
		||||
namespace ftxui {
 | 
			
		||||
 | 
			
		||||
@@ -31,13 +32,14 @@ Element Input::Render() {
 | 
			
		||||
  auto focused = 
 | 
			
		||||
    is_focused ? focus : select;
 | 
			
		||||
 | 
			
		||||
  // clang-format off
 | 
			
		||||
  return
 | 
			
		||||
    hbox(
 | 
			
		||||
      text(part_before_cursor),
 | 
			
		||||
      text(part_at_cursor) | underlined | focused,
 | 
			
		||||
      text(part_after_cursor)
 | 
			
		||||
    ) | flex | inverted | frame | main_decorator;
 | 
			
		||||
    
 | 
			
		||||
  // clang-format off
 | 
			
		||||
}
 | 
			
		||||
bool Input::OnEvent(Event event) {
 | 
			
		||||
  cursor_position = std::max(0, std::min<int>(content.size(), cursor_position));
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
#include "ftxui/component/menu.hpp"
 | 
			
		||||
#include <algorithm>
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include <algorithm>
 | 
			
		||||
 | 
			
		||||
namespace ftxui {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
#include "ftxui/component/radiobox.hpp"
 | 
			
		||||
#include <functional>
 | 
			
		||||
#include <algorithm>
 | 
			
		||||
 | 
			
		||||
namespace ftxui {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,7 @@
 | 
			
		||||
#include "ftxui/component/component.hpp"
 | 
			
		||||
#include "ftxui/screen/string.hpp"
 | 
			
		||||
#include "ftxui/screen/terminal.hpp"
 | 
			
		||||
#include <algorithm>
 | 
			
		||||
 | 
			
		||||
#if defined(__clang__) && defined (__APPLE__)
 | 
			
		||||
    // Quick exit is missing in standard CLang headers
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,5 @@
 | 
			
		||||
#include "ftxui/component/toggle.hpp"
 | 
			
		||||
#include <algorithm>
 | 
			
		||||
 | 
			
		||||
namespace ftxui {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user