@@ -50,6 +50,7 @@ class Ricin.ChatView : Gtk.Box {
5050
5151 [Signal (action = true )] private signal void copy_messages_selection ();
5252 [Signal (action = true )] private signal void quote_messages_selection ();
53+ [Signal (action = true )] private signal void entry_insert_newline ();
5354
5455 public Tox . Friend fr;
5556 private weak Tox . Tox handle;
@@ -59,7 +60,7 @@ class Ricin.ChatView : Gtk.Box {
5960 private Settings settings;
6061
6162 private Tox . UserStatus last_status;
62- private string last_message_sender;
63+ private string last_message_sender { get ; set ; default = " ricin " ; }
6364 private string last_message = null ;
6465 private bool is_bottom = true ;
6566
@@ -401,21 +402,21 @@ class Ricin.ChatView : Gtk.Box {
401402 string txt = " " ;
402403
403404 if (item is MessageListRow ) {
404- name = ((MessageListRow ) item). author;
405+ name = " [ " + ((MessageListRow ) item). author + " ] " ;
405406 txt = ((MessageListRow ) item). label_message. get_text ();
406407 } else if (item is SystemMessageListRow ) {
407408 name = " * " ;
408409 txt = ((SystemMessageListRow ) item). label_message. get_text ();
409410 } else if (item is QuoteMessageListRow ) {
410- name = ((QuoteMessageListRow ) item). author;
411+ name = " [ " + ((QuoteMessageListRow ) item). author + " ] " ;
411412 txt = ((QuoteMessageListRow ) item). get_quote ();
412413 }
413414
414415 if (as_quote) {
415416 sb. append_c (' >' );
416417 }
417418 if (include_names) {
418- sb. append (@" [ $name ] " );
419+ sb. append (@" $name " );
419420 }
420421
421422 sb. append (txt);
@@ -442,6 +443,8 @@ class Ricin.ChatView : Gtk.Box {
442443 string selection = this . get_selected_messages (false , true );
443444 Gtk . Clipboard . get (Gdk . SELECTION_CLIPBOARD ). set_text (selection, - 1 );
444445 this . messages_list. unselect_all ();
446+ this . entry. grab_focus_without_selecting ();
447+ this . entry. set_position (- 1 );
445448 });
446449 menu_copy_quote. activate. connect (() = > {
447450 if (this . messages_selected () == false ) {
@@ -451,6 +454,8 @@ class Ricin.ChatView : Gtk.Box {
451454 string quote = this . get_selected_messages (true , true );
452455 Gtk . Clipboard . get (Gdk . SELECTION_CLIPBOARD ). set_text (quote, - 1 );
453456 this . messages_list. unselect_all ();
457+ this . entry. grab_focus_without_selecting ();
458+ this . entry. set_position (- 1 );
454459 });
455460 menu_quote_selection. activate. connect (() = > {
456461 if (this . messages_selected () == false ) {
@@ -461,6 +466,7 @@ class Ricin.ChatView : Gtk.Box {
461466 this . entry. set_text (quote);
462467 this . messages_list. unselect_all ();
463468 this . entry. grab_focus_without_selecting ();
469+ this . entry. set_position (- 1 );
464470 });
465471
466472 menu. append (menu_copy_selection);
@@ -484,13 +490,21 @@ class Ricin.ChatView : Gtk.Box {
484490 });
485491 }
486492
493+ /* private MainWindow get_top () {
494+
495+ }*/
496+
487497 private void init_messages_shortcuts () {
488- var main_window = ((MainWindow ) this . get_toplevel ());
489- Gtk . AccelGroup accel_group = new Gtk .AccelGroup ();
490- main_window. add_accel_group (accel_group);
498+ // var main_window = ((MainWindow) this.get_toplevel ().get_toplevel ());
499+
491500 /**
492- * Keyboard shortcut for copying or quoting selected messages.
501+ * Shortcut for Ctrl+C: Copy selected messages if selection > 0
493502 **/
503+ this . add_accelerator (
504+ " copy-messages-selection" , MainWindow . accel_group, Gdk . keyval_from_name(" C" ),
505+ Gdk . ModifierType . CONTROL_MASK , Gtk . AccelFlags . VISIBLE
506+ );
507+
494508 this . copy_messages_selection. connect (() = > {
495509 if (this . messages_selected () == false ) {
496510 return ;
@@ -499,8 +513,18 @@ class Ricin.ChatView : Gtk.Box {
499513 string selection = this . get_selected_messages (false , true );
500514 Gtk . Clipboard . get (Gdk . SELECTION_CLIPBOARD ). set_text (selection, - 1 );
501515 this . messages_list. unselect_all ();
516+ this . entry. grab_focus_without_selecting ();
517+ this . entry. set_position (- 1 );
502518 });
503519
520+ /**
521+ * Shortcut for Ctrl+Shift+Q: Quote selected messages if selection > 0
522+ **/
523+ this . add_accelerator (
524+ " quote-messages-selection" , MainWindow . accel_group, Gdk . keyval_from_name(" Q" ),
525+ Gdk . ModifierType . CONTROL_MASK | Gdk . ModifierType . SHIFT_MASK , Gtk . AccelFlags . VISIBLE
526+ );
527+
504528 this . quote_messages_selection. connect (() = > {
505529 if (this . messages_selected () == false ) {
506530 return ;
@@ -510,23 +534,29 @@ class Ricin.ChatView : Gtk.Box {
510534 this . entry. set_text (quote);
511535 this . messages_list. unselect_all ();
512536 this . entry. grab_focus_without_selecting ();
537+ this . entry. set_position (- 1 );
513538 });
514539
515540 /**
516- * Shortcut for Ctrl+C: Copy selected messages if selection > 0
541+ * Shortcut for Shift+Enter in this.entry: Add a newline (\n).
517542 **/
518543 this . add_accelerator (
519- " copy-messages-selection " , accel_group, Gdk . keyval_from_name( " C " ) ,
520- Gdk . ModifierType . CONTROL_MASK , Gtk . AccelFlags . VISIBLE
544+ " entry-insert-newline " , MainWindow . accel_group, Gdk . Key . Return ,
545+ Gdk . ModifierType . SHIFT_MASK , Gtk . AccelFlags . VISIBLE
521546 );
522547
523- /**
524- * Shortcut for Ctrl+Shift+Q: Quote selected messages if selection > 0
525- **/
526- this . add_accelerator (
527- " quote-messages-selection" , accel_group, Gdk . keyval_from_name(" Q" ),
528- Gdk . ModifierType . CONTROL_MASK | Gdk . ModifierType . SHIFT_MASK , Gtk . AccelFlags . VISIBLE
529- );
548+ this . entry_insert_newline. connect (() = > {
549+ debug (" entry_insert_newline: Called." );
550+
551+ int cursor_position = this . entry. get_position ();
552+ string text = this . entry. get_text ();
553+ string newline = " \n " ;
554+
555+ this . entry. insert_at_cursor (newline);
556+ this . entry. grab_focus_without_selecting ();
557+ this . entry. set_position (cursor_position + newline. length);
558+
559+ });
530560 }
531561
532562 public void show_notice (string text , string icon_name = "help -info -symbolic ") {
0 commit comments