8 #ifndef Guit_TextItem_hpp
9 #define Guit_TextItem_hpp
44 GTextItem(GString
const& css_and_text =
"");
47 GTextItem* toTextItem()
override {
return this;}
54 void setValue(GString
const& str)
override;
55 void add(GString
const&)
override;
60 GString
text()
const override;
68 virtual float floatValue()
const;
92 void caretRowColumn(
int& row,
int& column);
99 void setCaretRowColumn(
int row,
int column);
107 void setCaretIndex(ssize_t index);
115 ssize_t indexToPos(ssize_t index)
const;
120 void findCaretRowColumn(ssize_t index,
int& line,
int& column);
122 void moveCaretRight(ssize_t count,
bool scroll_one);
123 void moveCaretLeft();
125 void moveCaretDown();
126 void insertText(GString
const& text);
127 void deleteChar(
bool before_caret);
129 bool deleteSelection();
130 void copyOrCut(
bool cut);
136 static GType& Type();
137 GType& type()
const override {
return Type();}
142 ssize_t offset, caret, selbegin, selend;
146 const class GMarginValue* margin_{};
147 GTextAttributes* attrlist_{};
148 void addProp(GProp&,
bool add_to_proplist)
override;
149 void pack(GRender* parent_render)
override;
150 ssize_t findCaretIndexInRow(ssize_t begin, ssize_t end,
float caretX);
151 bool keyCB(
class GKeyEvent&);
152 void selectAllTextCB();
157 GTextItem& TextItem(GString
const& css_and_text =
"");
162 class GTextField :
public GTextItem {
164 GTextField(GString
const& css_and_text =
"");
165 GTextField& clone(GClone
const&)
override;
167 using GTextItem::operator=;
169 using GType = GadgetType_<GTextField,GTextItem>;
170 static GType& Type();
171 GType& type()
const override {
return Type();}
175 GTextField& TextField(GString
const& css_and_text =
"");
180 class GTextArea :
public GTextItem {
182 GTextArea(GString
const& css_and_text =
"");
183 GTextArea& clone(GClone
const&)
override;
185 using GTextItem::operator=;
187 using GType = GadgetType_<GTextArea,GTextItem>;
188 static GType& Type();
189 GType& type()
const override {
return Type();}
193 GTextArea& TextArea(GString
const& css_and_text =
"");
200 GTextAttr(
size_t pos_in_text,
size_t length);
202 size_t pos_{}, len_{};
216 void adjust(
size_t pos, ssize_t delta);
218 std::vector<GTextAttr*> list_;