mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:58:11 +00:00
IRCClient+LibGUI: Add an input box so we can send messages to channels.
Implement this using a GTextEditor with a special single-line mode. This new mode needs some polishing, but it's already very useful.
This commit is contained in:
parent
ad08165a25
commit
1fc283ed7d
12 changed files with 126 additions and 23 deletions
|
@ -62,9 +62,14 @@ private:
|
|||
|
||||
class GTextEditor : public GWidget {
|
||||
public:
|
||||
explicit GTextEditor(GWidget* parent);
|
||||
enum Type { MultiLine, SingleLine };
|
||||
GTextEditor(Type, GWidget* parent);
|
||||
virtual ~GTextEditor() override;
|
||||
|
||||
Type type() const { return m_type; }
|
||||
bool is_single_line() const { return m_type == SingleLine; }
|
||||
bool is_multi_line() const { return m_type == MultiLine; }
|
||||
|
||||
Function<void(GTextEditor&)> on_cursor_change;
|
||||
|
||||
void set_text(const String&);
|
||||
|
@ -84,11 +89,16 @@ public:
|
|||
|
||||
bool has_selection() const { return m_selection.is_valid(); }
|
||||
String selected_text() const;
|
||||
String text() const;
|
||||
|
||||
void clear();
|
||||
|
||||
void cut();
|
||||
void copy();
|
||||
void paste();
|
||||
|
||||
Function<void(GTextEditor&)> on_return_pressed;
|
||||
|
||||
private:
|
||||
virtual void paint_event(GPaintEvent&) override;
|
||||
virtual void resize_event(GResizeEvent&) override;
|
||||
|
@ -141,6 +151,8 @@ private:
|
|||
void insert_at_cursor_or_replace_selection(const String&);
|
||||
void delete_selection();
|
||||
|
||||
Type m_type { MultiLine };
|
||||
|
||||
GScrollBar* m_vertical_scrollbar { nullptr };
|
||||
GScrollBar* m_horizontal_scrollbar { nullptr };
|
||||
GWidget* m_corner_widget { nullptr };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue