Skip to content

Commit

Permalink
copy link to node and copy anchor link to include absolute path to th…
Browse files Browse the repository at this point in the history
…e cherrytree document and hierarchical path to node (#2452)
  • Loading branch information
giuspen committed Jun 29, 2024
1 parent 1599cf2 commit 5a7b5a4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ct/ct_clipboard.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* ct_clipboard.cc
*
* Copyright 2009-2023
* Copyright 2009-2024
* Giuseppe Penone <[email protected]>
* Evgenii Gurianov <https://github.com/txe>
*
Expand Down Expand Up @@ -236,7 +236,7 @@ void CtClipboard::node_link_to_clipboard(CtTreeIter node)
CtClipboardData* clip_data = new CtClipboardData{};
std::string tml = R"XML(<?xml version="1.0" encoding="UTF-8"?><root><slot><rich_text link="node {}">{}</rich_text></slot></root>)XML";
clip_data->rich_text = fmt::format(tml, node.get_node_id(), str::xml_escape(node.get_node_name()));
clip_data->plain_text = "node: " + node.get_node_name();
clip_data->plain_text = fmt::format("{} - {}", node.get_cherrytree_filepath(), CtMiscUtil::get_node_hierarchical_name(node, " / ", false/*for_filename*/).c_str());

_set_clipboard_data({CtConst::TARGET_CTD_RICH_TEXT, CtConst::TARGET_CTD_PLAIN_TEXT}, clip_data);
}
Expand All @@ -246,7 +246,7 @@ void CtClipboard::anchor_link_to_clipboard(CtTreeIter node, const Glib::ustring&
CtClipboardData* clip_data = new CtClipboardData{};
std::string tml = R"XML(<?xml version="1.0" encoding="UTF-8"?><root><slot><rich_text link="node {} {}">{}</rich_text></slot></root>)XML";
clip_data->rich_text = fmt::format(tml, node.get_node_id(), str::xml_escape(anchor_name), str::xml_escape(anchor_name));
clip_data->plain_text = "anchor: " + anchor_name;
clip_data->plain_text = fmt::format("{} - {} - {}", node.get_cherrytree_filepath(), CtMiscUtil::get_node_hierarchical_name(node, " / ", false/*for_filename*/).c_str(), anchor_name);

_set_clipboard_data({CtConst::TARGET_CTD_RICH_TEXT, CtConst::TARGET_CTD_PLAIN_TEXT}, clip_data);
}
Expand Down
6 changes: 6 additions & 0 deletions src/ct/ct_treestore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,12 @@ void CtTreeIter::pending_new_db_node()
_pCtMainWin->get_ct_storage()->pending_new_db_node(get_node_id());
}

const char* CtTreeIter::get_cherrytree_filepath() const
{
CtStorageControl* pCtStorageControl = _pCtMainWin->get_ct_storage();
return pCtStorageControl ? pCtStorageControl->get_file_path().c_str() : "";
}

CtTreeStore::CtTreeStore(CtMainWin* pCtMainWin)
: _pCtMainWin{pCtMainWin}
{
Expand Down
2 changes: 2 additions & 0 deletions src/ct/ct_treestore.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ class CtTreeIter : public Gtk::TreeIter
void pending_edit_db_node_hier();
void pending_new_db_node();

const char* get_cherrytree_filepath() const;

static int get_pango_weight_from_is_bold(const bool isBold);
static bool get_is_bold_from_pango_weight(const int pangoWeight);

Expand Down

0 comments on commit 5a7b5a4

Please sign in to comment.