a bool param to determines whether the caret move to end of text

This commit is contained in:
Jinhao
2016-05-10 15:52:06 +08:00
parent 79f484dd2e
commit df68cfa3ad
7 changed files with 61 additions and 35 deletions

View File

@@ -112,21 +112,19 @@ namespace nana{
struct root_misc
{
typedef basic_window core_window_t;
core_window_t * window;
basic_window * window;
nana::paint::graphics root_graph;
shortkey_container shortkeys;
struct condition_rep
{
bool ignore_tab{ false }; //ignore tab when the focus is changed by pressing tab.
core_window_t* pressed{nullptr}; //The handle to a window which has been pressed by pressing left button of mouse.
core_window_t* pressed_by_space{ nullptr }; //The handle to a window which has been pressed by pressing spacebar.
core_window_t* hovered{nullptr}; //the latest window that mouse moved
bool ignore_tab{ false }; //ignore tab when the focus is changed by TAB key.
basic_window* pressed{ nullptr }; //The handle to a window which has been pressed by mouse left button.
basic_window* pressed_by_space{ nullptr }; //The handle to a window which has been pressed by SPACEBAR key.
basic_window* hovered{ nullptr }; //the latest window that mouse moved
}condition;
root_misc(core_window_t * wd, unsigned width, unsigned height)
root_misc(basic_window * wd, unsigned width, unsigned height)
: window(wd),
root_graph({ width, height })
{}

View File

@@ -42,6 +42,12 @@ namespace nana{ namespace widgets
using command = EnumCommand;
using container = std::deque < std::unique_ptr<undoable_command_interface<command>> >;
void clear()
{
commands_.clear();
pos_ = 0;
}
void max_steps(std::size_t maxs)
{
max_steps_ = maxs;
@@ -58,7 +64,7 @@ namespace nana{ namespace widgets
{
enabled_ = enb;
if (!enb)
commands_.clear();
clear();
}
bool enabled() const
@@ -204,7 +210,7 @@ namespace nana{ namespace widgets
unsigned screen_lines() const;
bool getline(std::size_t pos, ::std::wstring&) const;
void text(std::wstring);
void text(std::wstring, bool end_caret);
std::wstring text() const;
/// Sets caret position through text coordinate.

View File

@@ -1,7 +1,7 @@
/**
* A Textbox Implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -138,8 +138,14 @@ namespace nana
/// @param generator generates text for identing a line. If it is empty, textbox indents the line according to last line.
textbox& indention(bool, std::function<std::string()> generator = {});
//A workaround for reset, explicit default constructor syntax, because VC2013 incorrectly treats {} as {0}.
textbox& reset(const std::string& = std::string()); ///< discard the old text and set a new text
/// Discards the old text and set a new text. It also clears the filename/edited flags and undo command.
/// A workaround for reset, explicit default constructor syntax, because VC2013 incorrectly treats {} as {0}.
/*
* @param text A new text replaces the old text.
* @param end_caret Indicates whether to position the caret to the end of text.
* @return a reference of *this.
*/
textbox& reset(const std::string& text = std::string(), bool end_caret = true); ///< discard the old text and set a new text
/// The file of last store operation.
std::string filename() const;