highlight certain lines in a textbox(#194)
This commit is contained in:
@@ -90,6 +90,8 @@ namespace nana{ namespace widgets
|
||||
void set_keyword(const ::std::wstring& kw, const std::string& name, bool case_sensitive, bool whole_word_matched);
|
||||
void erase_keyword(const ::std::wstring& kw);
|
||||
|
||||
colored_area_access_interface& colored_area();
|
||||
|
||||
void set_accept(std::function<bool(char_type)>);
|
||||
void set_accept(accepts);
|
||||
bool respond_char(const arg_keyboard& arg);
|
||||
@@ -211,6 +213,7 @@ namespace nana{ namespace widgets
|
||||
|
||||
bool try_refresh();
|
||||
private:
|
||||
nana::color _m_draw_colored_area(paint::graphics& graph, std::size_t line_pos);
|
||||
std::vector<upoint> _m_render_text(const ::nana::color& text_color);
|
||||
void _m_pre_calc_lines(std::size_t line_off, std::size_t lines);
|
||||
|
||||
|
||||
@@ -40,6 +40,29 @@ namespace nana
|
||||
|
||||
virtual void text_exposed(const std::vector<upoint>&) = 0;
|
||||
};
|
||||
|
||||
struct colored_area_type
|
||||
{
|
||||
const ::std::size_t begin; ///< The begin line position
|
||||
::std::size_t count; ///< The number of lines
|
||||
|
||||
::nana::color bgcolor;
|
||||
::nana::color fgcolor;
|
||||
};
|
||||
|
||||
class colored_area_access_interface
|
||||
{
|
||||
public:
|
||||
using colored_area_type = skeletons::colored_area_type;
|
||||
|
||||
virtual ~colored_area_access_interface();
|
||||
|
||||
virtual std::shared_ptr<colored_area_type> get(std::size_t line_pos) = 0;
|
||||
virtual bool clear() = 0;
|
||||
virtual bool remove(std::size_t line_pos) = 0;
|
||||
virtual std::size_t size() const = 0;
|
||||
virtual std::shared_ptr<colored_area_type> at(std::size_t index) = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,9 +100,12 @@ namespace nana
|
||||
:public widget_object<category::widget_tag, drawerbase::textbox::drawer, drawerbase::textbox::textbox_events, ::nana::widgets::skeletons::text_editor_scheme>
|
||||
{
|
||||
public:
|
||||
using text_focus_behavior = widgets::skeletons::text_focus_behavior;
|
||||
using colored_area_type = widgets::skeletons::colored_area_type;
|
||||
using colored_area_access_interface = widgets::skeletons::colored_area_access_interface;
|
||||
|
||||
using text_focus_behavior = widgets::skeletons::text_focus_behavior;
|
||||
using text_positions = std::vector<upoint>;
|
||||
|
||||
/// The default constructor without creating the widget.
|
||||
textbox();
|
||||
|
||||
@@ -134,6 +137,8 @@ namespace nana
|
||||
void store(std::string file);
|
||||
void store(std::string file, nana::unicode encoding);
|
||||
|
||||
colored_area_access_interface* colored_area_access();
|
||||
|
||||
/// Enables/disables the textbox to indent a line. Idents a new line when it is created by pressing enter.
|
||||
/// @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 = {});
|
||||
|
||||
Reference in New Issue
Block a user