Skip to content

Commit

Permalink
fixed right click -> copy link not working if there is a text selecti…
Browse files Browse the repository at this point in the history
…on (#2362)
  • Loading branch information
giuspen committed Jun 3, 2024
1 parent 7a5cee4 commit e94facd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/ct/ct_actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ class CtActions
Gtk::TextIter* iter_bound);
bool _on_embfiles_sentinel_timeout();
void _exec_code(const bool is_all);
void _link_right_click_pre_action();

public:
// others actions
Expand Down
20 changes: 16 additions & 4 deletions src/ct/ct_actions_others.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,33 +38,45 @@
#include <vte/vte.h>
#endif // HAVE_VTE

void CtActions::_link_right_click_pre_action()
{
if (_curr_buffer()->get_has_selection() and _pCtMainWin->hovering_link_iter_offset() >= 0) {
Gtk::TextIter target_iter = _curr_buffer()->get_iter_at_offset(_pCtMainWin->hovering_link_iter_offset());
if (target_iter) _curr_buffer()->place_cursor(target_iter);
}
}

void CtActions::link_cut()
{
if (not _is_curr_node_not_read_only_or_error()) return;
if (!_link_check_around_cursor().empty()) {
_link_right_click_pre_action();
if (not _link_check_around_cursor().empty()) {
g_signal_emit_by_name(G_OBJECT(_pCtMainWin->get_text_view().gobj()), "cut-clipboard");
}
}

void CtActions::link_copy()
{
if (!_link_check_around_cursor().empty()) {
_link_right_click_pre_action();
if (not _link_check_around_cursor().empty()) {
g_signal_emit_by_name(G_OBJECT(_pCtMainWin->get_text_view().gobj()), "copy-clipboard");
}
}

void CtActions::link_dismiss()
{
if (not _is_curr_node_not_read_only_or_error()) return;
if (!_link_check_around_cursor().empty()) {
_link_right_click_pre_action();
if (not _link_check_around_cursor().empty()) {
remove_text_formatting();
}
}

void CtActions::link_delete()
{
if (not _is_curr_node_not_read_only_or_error()) return;
if (!_link_check_around_cursor().empty()) {
_link_right_click_pre_action();
if (not _link_check_around_cursor().empty()) {
_curr_buffer()->erase_selection(true, _pCtMainWin->get_text_view().get_editable());
_pCtMainWin->get_text_view().grab_focus();
}
Expand Down

0 comments on commit e94facd

Please sign in to comment.