14 #ifndef T3_WIDGET_TEXTBUFFER_H
15 #define T3_WIDGET_TEXTBUFFER_H
21 #include <t3widget/key.h>
22 #include <t3widget/textline.h>
23 #include <t3widget/undo.h>
24 #include <t3widget/interfaces.h>
28 typedef std::vector<text_line_t *> lines_t;
37 struct T3_WIDGET_LOCAL implementation_t {
41 selection_mode_t selection_mode;
45 undo_type_t last_undo_type;
50 implementation_t(
text_line_factory_t *_line_factory) : selection_start(-1, 0), selection_end(-1, 0),
51 selection_mode(selection_mode_t::NONE), last_undo_type(UNDO_NONE), last_undo(NULL),
52 line_factory(_line_factory == NULL ? &default_text_line_factory : _line_factory)
55 pimpl_ptr<implementation_t>::t impl;
58 undo_t *get_undo(undo_type_t type);
62 void set_undo_mark(
void);
64 void locate_pos(
void);
68 int apply_undo_redo(undo_type_t type,
undo_t *current);
69 bool merge_internal(
int line);
70 bool break_line_internal(
const std::string *indent = NULL);
72 bool undo_indent_selection(
undo_t *undo, undo_type_t type);
77 virtual void prepare_paint_line(
int line);
86 bool insert_char(
key_t c);
87 bool overwrite_char(
key_t c);
88 bool delete_char(
void);
89 bool backspace_char(
void);
90 bool merge(
bool backspace);
91 bool break_line(
const std::string *indent = NULL);
92 bool insert_block(
const std::string *block);
94 bool append_text(
const char *text);
95 bool append_text(
const char *text,
size_t _size);
96 bool append_text(
const std::string *text);
98 int get_line_max(
int line)
const;
99 void adjust_position(
int adjust);
100 int width_at_cursor(
void)
const;
103 void goto_next_word(
void);
104 void goto_previous_word(
void);
107 int calculate_line_pos(
int line,
int pos,
int tabsize)
const;
111 void set_selection_end(
bool update_primary =
true);
112 void set_selection_mode(selection_mode_t mode);
113 selection_mode_t get_selection_mode(
void)
const;
114 bool selection_empty(
void)
const;
117 bool indent_selection(
int tabsize,
bool tab_spaces);
119 bool unindent_selection(
int tabsize);
121 bool unindent_line(
int tabsize);
138 bool is_modified(
void)
const;
140 int apply_undo(
void);
141 int apply_redo(
void);
142 void start_undo_block(
void);
143 void end_undo_block(
void);
145 void goto_next_word_boundary(
void);
146 void goto_previous_word_boundary(
void);
151 T3_WIDGET_SIGNAL(rewrap_required,
void, rewrap_type_t,
int,
int);