aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/conversation_view.vala
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/ui/conversation_view.vala')
-rw-r--r--main/src/ui/conversation_view.vala27
1 files changed, 27 insertions, 0 deletions
diff --git a/main/src/ui/conversation_view.vala b/main/src/ui/conversation_view.vala
index af7e32c1..47d54f92 100644
--- a/main/src/ui/conversation_view.vala
+++ b/main/src/ui/conversation_view.vala
@@ -17,6 +17,33 @@ public class ConversationView : Gtk.Overlay {
construct {
white_revealer.notify["child-revealed"].connect_after(on_child_revealed_changed);
+ conversation_frame.on_quote_text.connect((t, text) => on_quote_text(text));
+ }
+
+ public void on_quote_text(string text) {
+ unowned TextBuffer buffer = chat_input.chat_text_view.text_view.buffer;
+ string text_to_quote = text;
+
+ Regex quotes = new Regex("((?<=\n)>.*(\n|$))|(^>.*(\n|$))");
+ Regex whitespace = new Regex("(\n *){2,}");
+ Regex first_column = new Regex("(^|\n)(.+)");
+ Regex end = new Regex("\n*$");
+
+ text_to_quote = quotes.replace(text_to_quote, -1, 0, "");
+ text_to_quote = whitespace.replace(text_to_quote, -1, 0, "\n");
+ text_to_quote = "%s".printf(text_to_quote);
+
+ text_to_quote = first_column.replace(text_to_quote, -1, 0, "\\1> \\2");
+
+ string to_replace = "\n";
+ if(buffer.cursor_position > 0) {
+ to_replace = "";
+ text_to_quote = "\n" + text_to_quote;
+ }
+
+ text_to_quote = end.replace(text_to_quote, -1, 0, to_replace);
+
+ buffer.insert_at_cursor(text_to_quote, -1);
}
public void add_overlay_dialog(Widget widget) {