Position type for text plugin. More...
#include <text_base_types.h>
Public Member Functions | |
Position (unsigned int paragraph_index=0, unsigned int offset=0) | |
Constructors and destructors. | |
Position (const std::string &from_string) | |
Position (const Position &r) | |
Position & | operator= (const Position &r) |
~Position () | |
std::string | to_string () const |
Convert internel position type to string. The string-based position can be used as anchors. | |
Data Fields | |
unsigned int | paragraph |
unsigned int | offset |
Friends | |
bool | operator== (const Position &l, const Position &r) |
bool | operator!= (const Position &l, const Position &r) |
bool | operator< (const Position &l, const Position &r) |
bool | operator> (const Position &l, const Position &r) |
bool | operator<= (const Position &l, const Position &r) |
bool | operator>= (const Position &l, const Position &r) |
Position type for text plugin.
Definition at line 60 of file text_base_types.h.
text::Position::Position | ( | unsigned int | paragraph_index = 0 , |
|
unsigned int | offset = 0 | |||
) | [explicit] |
Constructors and destructors.
Definition at line 33 of file text_base_types.cpp.
text::Position::Position | ( | const std::string & | from_string | ) | [explicit] |
Definition at line 39 of file text_base_types.cpp.
References ERRORPRINTF, offset, and paragraph.
00040 { 00041 if (from_string == "") 00042 { 00043 paragraph = offset = 0; 00044 } 00045 else 00046 { 00047 if (2 != sscanf(from_string.c_str(), "txt://%d:%d", ¶graph, &offset)) 00048 { 00049 // Invalid anchor. 00050 ERRORPRINTF("Invalid text anchor detected!"); 00051 paragraph = offset = 0; 00052 } 00053 } 00054 }
text::Position::Position | ( | const Position & | r | ) | [inline] |
text::Position::~Position | ( | ) |
Definition at line 56 of file text_base_types.cpp.
std::string text::Position::to_string | ( | ) | const |
Convert internel position type to string. The string-based position can be used as anchors.
Definition at line 60 of file text_base_types.cpp.
References offset, and paragraph.
Referenced by text::PluginViewImpl::get_anchor_from_coordinates_impl(), text::TextModel::get_words_from_range(), and text::RangeImpl::RangeImpl().
00061 { 00062 char buf[32]; 00063 g_snprintf(buf, 32, "txt://%d:%d", paragraph, offset); 00064 return std::string(buf); 00065 }
Definition at line 91 of file text_base_types.h.
Definition at line 96 of file text_base_types.h.
Definition at line 108 of file text_base_types.h.
Definition at line 86 of file text_base_types.h.
Definition at line 102 of file text_base_types.h.
Definition at line 114 of file text_base_types.h.
unsigned int text::Position::offset |
Definition at line 129 of file text_base_types.h.
Referenced by text::TextView::calculate_next_page_pos(), text::TextView::calculate_prev_page_pos(), text::TextModel::get_file_pos_from_anchor(), text::TextModel::get_text_from_range(), text::TextModel::get_word_from_anchor(), text::TextModel::get_words_from_range(), handle_event(), text::TextModel::has_anchor(), main(), text::TextView::map_doc_pos_to_view_pos(), text::TextView::map_view_pos_to_doc_pos(), operator=(), Position(), text::TextView::render(), text::TextModel::search(), to_string(), and widget_event_handler().
unsigned int text::Position::paragraph |
Definition at line 128 of file text_base_types.h.
Referenced by text::TextView::calculate_next_page_pos(), text::TextView::calculate_prev_page_pos(), text::TextModel::get_file_pos_from_anchor(), text::TextView::get_page_anchor_by_anchor(), text::TextModel::get_text_from_range(), text::TextModel::get_word_from_anchor(), text::TextModel::get_words_from_range(), handle_event(), text::TextModel::has_anchor(), main(), text::TextView::map_doc_pos_to_view_pos(), text::TextView::map_view_pos_to_doc_pos(), operator=(), Position(), text::TextView::render(), text::TextModel::search(), to_string(), and widget_event_handler().