New textbox::getline returning an optional<string>
This commit is contained in:
parent
56a9647d56
commit
e08bb0bfe1
@ -17,6 +17,8 @@
|
||||
#include "skeletons/textbase_export_interface.hpp"
|
||||
#include "skeletons/text_editor_part.hpp"
|
||||
|
||||
#include <nana/optional.hpp>
|
||||
|
||||
namespace nana
|
||||
{
|
||||
class textbox;
|
||||
@ -173,6 +175,13 @@ namespace nana
|
||||
/// Read the text from a specified line with a set offset. It returns true for success.
|
||||
bool getline(std::size_t line_index,std::size_t offset,std::string& text) const;
|
||||
|
||||
/// Read the text from a specified line; returns an empty optional on failure
|
||||
std::optional<std::string> getline(std::size_t pos) const;
|
||||
|
||||
///Read the text from a specified line with a set offset. Returns an empty optional for
|
||||
/// failure.
|
||||
std::optional<std::string> getline(std::size_t line_index, std::size_t offset) const;
|
||||
|
||||
/// Gets the caret position
|
||||
/// Returns true if the caret is in the area of display, false otherwise.
|
||||
bool caret_pos(point& pos, bool text_coordinate) const;
|
||||
|
@ -377,6 +377,27 @@ namespace drawerbase {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::optional<std::string> textbox::getline(std::size_t pos) const
|
||||
{
|
||||
auto result = std::string{};
|
||||
if ( getline(pos, result) )
|
||||
{
|
||||
return { std::move(result) };
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
std::optional<std::string> textbox::getline(std::size_t line_index, std::size_t offset) const
|
||||
{
|
||||
auto result = std::string{};
|
||||
if ( getline(line_index, offset, result) )
|
||||
{
|
||||
return { std::move(result) };
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
/// Gets the caret position
|
||||
bool textbox::caret_pos(point& pos, bool text_coordinate) const
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user