mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-12-16 01:48:56 +08:00
Multiple fixes: signed/unsigned, etc... (#600)
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
#include <algorithm> // for max, min
|
||||
#include <cstddef> // for size_t
|
||||
#include <functional> // for function
|
||||
#include <memory> // for __shared_ptr_access, shared_ptr, allocator
|
||||
#include <memory> // for __shared_ptr_access, allocator, shared_ptr
|
||||
#include <string> // for string
|
||||
|
||||
#include "ftxui/component/component.hpp" // for Maybe, Checkbox, Make, Radiobox, Vertical, Dropdown
|
||||
#include "ftxui/component/component_base.hpp" // for Component, ComponentBase
|
||||
#include "ftxui/component/component_options.hpp" // for CheckboxOption, EntryState
|
||||
#include "ftxui/dom/elements.hpp" // for operator|, Element, border, filler, operator|=, separator, size, text, vbox, frame, vscroll_indicator, hbox, HEIGHT, LESS_THAN, bold, inverted
|
||||
#include "ftxui/screen/util.hpp" // for clamp
|
||||
#include "ftxui/util/ref.hpp" // for ConstStringListRef
|
||||
|
||||
namespace ftxui {
|
||||
@@ -38,8 +39,8 @@ Component Dropdown(ConstStringListRef entries, int* selected) {
|
||||
}
|
||||
|
||||
Element Render() override {
|
||||
*selected_ = std::min((int)entries_.size() - 1, std::max(0, *selected_));
|
||||
title_ = entries_[*selected_];
|
||||
*selected_ = util::clamp(*selected_, 0, (int)entries_.size() - 1);
|
||||
title_ = entries_[static_cast<size_t>(*selected_)];
|
||||
if (show_) {
|
||||
const int max_height = 12;
|
||||
return vbox({
|
||||
|
||||
Reference in New Issue
Block a user