mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-05-06 09:13:48 +08:00
Fix errors. (#1010)
This commit is contained in:
parent
2c9a828402
commit
67163c2571
14
.github/workflows/build.yaml
vendored
14
.github/workflows/build.yaml
vendored
@ -19,18 +19,16 @@ jobs:
|
|||||||
- name: Linux GCC
|
- name: Linux GCC
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
compiler: gcc
|
compiler: gcc
|
||||||
gcov_executable: gcov
|
|
||||||
|
|
||||||
- name: Linux Clang
|
- name: Linux Clang
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
compiler: llvm
|
compiler: llvm
|
||||||
gcov_executable: "llvm-cov gcov"
|
gcov_executable: "llvm-cov gcov"
|
||||||
|
|
||||||
# https://github.com/aminya/setup-cpp/issues/246
|
- name: MacOS clang
|
||||||
#- name: MacOS clang
|
os: macos-latest
|
||||||
#os: macos-latest
|
compiler: llvm
|
||||||
#compiler: llvm
|
gcov_executable: "llvm-cov gcov"
|
||||||
#gcov_executable: "llvm-cov gcov"
|
|
||||||
|
|
||||||
- name: Windows MSVC
|
- name: Windows MSVC
|
||||||
os: windows-latest
|
os: windows-latest
|
||||||
@ -85,7 +83,7 @@ jobs:
|
|||||||
ctest -C Debug --rerun-failed --output-on-failure;
|
ctest -C Debug --rerun-failed --output-on-failure;
|
||||||
|
|
||||||
- name: Unix - coverage
|
- name: Unix - coverage
|
||||||
if: runner.os != 'Windows'
|
if: matrix.gcov_executable != ''
|
||||||
working-directory: ./build
|
working-directory: ./build
|
||||||
run: >
|
run: >
|
||||||
gcovr
|
gcovr
|
||||||
@ -106,7 +104,7 @@ jobs:
|
|||||||
--gcov-executable '${{ matrix.gcov_executable }}';
|
--gcov-executable '${{ matrix.gcov_executable }}';
|
||||||
|
|
||||||
- name: Windows - Test and coverage
|
- name: Windows - Test and coverage
|
||||||
if: runner.os == 'Windows'
|
if: runner.os == 'Windows' && false
|
||||||
working-directory: ./build
|
working-directory: ./build
|
||||||
run: >
|
run: >
|
||||||
OpenCppCoverage.exe
|
OpenCppCoverage.exe
|
||||||
|
76
.github/workflows/codeql.yml
vendored
76
.github/workflows/codeql.yml
vendored
@ -1,76 +0,0 @@
|
|||||||
# For most projects, this workflow file will not need changing; you simply need
|
|
||||||
# to commit it to your repository.
|
|
||||||
#
|
|
||||||
# You may wish to alter this file to override the set of languages analyzed,
|
|
||||||
# or to provide custom queries or build logic.
|
|
||||||
#
|
|
||||||
# ******** NOTE ********
|
|
||||||
# We have attempted to detect the languages in your repository. Please check
|
|
||||||
# the `language` matrix defined below to confirm you have the correct set of
|
|
||||||
# supported CodeQL languages.
|
|
||||||
#
|
|
||||||
name: "CodeQL"
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ "main" ]
|
|
||||||
pull_request:
|
|
||||||
# The branches below must be a subset of the branches above
|
|
||||||
branches: [ "main" ]
|
|
||||||
schedule:
|
|
||||||
- cron: '45 22 * * 5'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
analyze:
|
|
||||||
name: Analyze
|
|
||||||
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
|
|
||||||
permissions:
|
|
||||||
actions: read
|
|
||||||
contents: read
|
|
||||||
security-events: write
|
|
||||||
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
language: [ 'cpp' ]
|
|
||||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
|
||||||
# Use only 'java' to analyze code written in Java, Kotlin or both
|
|
||||||
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
|
|
||||||
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
|
||||||
- name: Initialize CodeQL
|
|
||||||
uses: github/codeql-action/init@v2
|
|
||||||
with:
|
|
||||||
languages: ${{ matrix.language }}
|
|
||||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
|
||||||
# By default, queries listed here will override any specified in a config file.
|
|
||||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
|
||||||
|
|
||||||
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
|
|
||||||
# queries: security-extended,security-and-quality
|
|
||||||
|
|
||||||
|
|
||||||
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
|
|
||||||
# If this step fails, then you should remove it and run the build manually (see below)
|
|
||||||
- name: Autobuild
|
|
||||||
uses: github/codeql-action/autobuild@v2
|
|
||||||
|
|
||||||
# ℹ️ Command-line programs to run using the OS shell.
|
|
||||||
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
|
||||||
|
|
||||||
# If the Autobuild fails above, remove it and uncomment the following three lines.
|
|
||||||
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
|
|
||||||
|
|
||||||
# - run: |
|
|
||||||
# echo "Run, Build Application using script"
|
|
||||||
# ./location_of_script_within_repo/buildscript.sh
|
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
|
||||||
uses: github/codeql-action/analyze@v2
|
|
||||||
with:
|
|
||||||
category: "/language:${{matrix.language}}"
|
|
@ -1,64 +1,9 @@
|
|||||||
// Copyright 2020 Arthur Sonzogni. All rights reserved.
|
#include "ftxui/component/component.hpp"
|
||||||
// Use of this source code is governed by the MIT license that can be found in
|
#include "ftxui/component/screen_interactive.hpp"
|
||||||
// the LICENSE file.
|
|
||||||
#include <memory> // for shared_ptr, __shared_ptr_access
|
|
||||||
#include <string> // for operator+, to_string
|
|
||||||
|
|
||||||
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
int main(){
|
||||||
#include "ftxui/component/component.hpp" // for Button, Horizontal, Renderer
|
auto screen = ftxui::ScreenInteractive::Fullscreen();
|
||||||
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
auto testComponent = ftxui::Renderer([](){return ftxui::text("test Component");});
|
||||||
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
screen.Loop(testComponent);
|
||||||
#include "ftxui/dom/elements.hpp" // for separator, gauge, text, Element, operator|, vbox, border
|
return 0;
|
||||||
|
|
||||||
using namespace ftxui;
|
|
||||||
|
|
||||||
// This is a helper function to create a button with a custom style.
|
|
||||||
// The style is defined by a lambda function that takes an EntryState and
|
|
||||||
// returns an Element.
|
|
||||||
// We are using `center` to center the text inside the button, then `border` to
|
|
||||||
// add a border around the button, and finally `flex` to make the button fill
|
|
||||||
// the available space.
|
|
||||||
ButtonOption Style() {
|
|
||||||
auto option = ButtonOption::Animated();
|
|
||||||
option.transform = [](const EntryState& s) {
|
|
||||||
auto element = text(s.label);
|
|
||||||
if (s.focused) {
|
|
||||||
element |= bold;
|
|
||||||
}
|
|
||||||
return element | center | borderEmpty | flex;
|
|
||||||
};
|
|
||||||
return option;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
int value = 50;
|
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
auto btn_dec_01 = Button("-1", [&] { value -= 1; }, Style());
|
|
||||||
auto btn_inc_01 = Button("+1", [&] { value += 1; }, Style());
|
|
||||||
auto btn_dec_10 = Button("-10", [&] { value -= 10; }, Style());
|
|
||||||
auto btn_inc_10 = Button("+10", [&] { value += 10; }, Style());
|
|
||||||
// clang-format on
|
|
||||||
|
|
||||||
// The tree of components. This defines how to navigate using the keyboard.
|
|
||||||
// The selected `row` is shared to get a grid layout.
|
|
||||||
int row = 0;
|
|
||||||
auto buttons = Container::Vertical({
|
|
||||||
Container::Horizontal({btn_dec_01, btn_inc_01}, &row) | flex,
|
|
||||||
Container::Horizontal({btn_dec_10, btn_inc_10}, &row) | flex,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Modify the way to render them on screen:
|
|
||||||
auto component = Renderer(buttons, [&] {
|
|
||||||
return vbox({
|
|
||||||
text("value = " + std::to_string(value)),
|
|
||||||
separator(),
|
|
||||||
buttons->Render() | flex,
|
|
||||||
}) |
|
|
||||||
flex | border;
|
|
||||||
});
|
|
||||||
|
|
||||||
auto screen = ScreenInteractive::FitComponent();
|
|
||||||
screen.Loop(component);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
@ -102,11 +102,11 @@ Element focus(Element child) {
|
|||||||
return std::make_shared<Focus>(unpack(std::move(child)));
|
return std::make_shared<Focus>(unpack(std::move(child)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @deprecated Use `focus` instead.
|
/// This is deprecated. Use `focus` instead.
|
||||||
/// @brief Set the `child` to be the one focused among its siblings.
|
/// @brief Set the `child` to be the one focused among its siblings.
|
||||||
/// @param child The element to be focused.
|
/// @param child The element to be focused.
|
||||||
Element select(Element e) {
|
Element select(Element child) {
|
||||||
return focus(std::move(e));
|
return focus(std::move(child));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Allow an element to be displayed inside a 'virtual' area. It size can
|
/// @brief Allow an element to be displayed inside a 'virtual' area. It size can
|
||||||
|
Loading…
Reference in New Issue
Block a user