[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 0490c33 4/6: Set clipboard text when pasting
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 0490c33 4/6: Set clipboard text when pasting census out |
Date: |
Mon, 18 Jun 2018 17:56:57 -0400 (EDT) |
branch: master
commit 0490c33d68d54dc5acd60d9b20b4f032049483ff
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Set clipboard text when pasting census out
IllustrationView::UponCopyFull() both writes a file and fills the
clipboard with its contents, so made CensusView::DoPasteCensusOut()
do likewise.
---
census_view.cpp | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/census_view.cpp b/census_view.cpp
index 0021a3b..7a6d5e0 100644
--- a/census_view.cpp
+++ b/census_view.cpp
@@ -36,6 +36,7 @@
#include "illustrator.hpp"
#include "input.hpp"
#include "input_sequence_entry.hpp"
+#include "istream_to_string.hpp"
#include "ledger.hpp"
#include "ledger_text_formats.hpp"
#include "miscellany.hpp" // is_ok_for_cctype(),
ios_out_app_binary()
@@ -1927,6 +1928,7 @@ void CensusView::UponPasteCensusOut(wxCommandEvent&)
void CensusView::DoPasteCensusOut() const
{
+ Timer timer;
std::vector<std::string> distinct_headers;
std::vector<std::string> const&
all_headers(case_parms()[0].member_names());
for(auto const& header : all_headers)
@@ -1947,13 +1949,13 @@ void CensusView::DoPasteCensusOut() const
std::string const& e = c.spreadsheet_file_extension();
std::string const f = fs::basename(base_filename()) + ".pasted_out.cns";
std::string file_name = unique_filepath(f, e).string();
- std::ofstream os(file_name.c_str(), ios_out_app_binary());
+ std::ofstream ofs(file_name.c_str(), ios_out_app_binary());
for(auto const& header : distinct_headers)
{
- os << header << '\t';
+ ofs << header << '\t';
}
- os << '\n';
+ ofs << '\n';
for(auto const& cell : cell_parms())
{
@@ -1966,13 +1968,20 @@ void CensusView::DoPasteCensusOut() const
int z = JdnToYmd(jdn_t(value_cast<int>(s))).value();
s = value_cast<std::string>(z);
}
- os << s << '\t';
+ ofs << s << '\t';
}
- os << '\n';
+ ofs << '\n';
}
- if(!os)
+ if(!ofs)
{
alarum() << "Unable to write '" << file_name << "'." << LMI_FLUSH;
}
+
+ ofs.close();
+ std::ifstream ifs(file_name.c_str());
+ std::string s;
+ istream_to_string(ifs, s);
+ ClipboardEx::SetText(s);
+ status() << "Paste out: " << timer.stop().elapsed_msec_str() << std::flush;
}
- [lmi-commits] [lmi] master updated (f9f89bd -> 2918ec8), Greg Chicares, 2018/06/18
- [lmi-commits] [lmi] master b3be110 1/6: Correct a syntax error in a comment, Greg Chicares, 2018/06/18
- [lmi-commits] [lmi] master c922787 2/6: Remove unnecessary parentheses, Greg Chicares, 2018/06/18
- [lmi-commits] [lmi] master 0490c33 4/6: Set clipboard text when pasting census out,
Greg Chicares <=
- [lmi-commits] [lmi] master 2918ec8 6/6: Remove scaffolding, Greg Chicares, 2018/06/18
- [lmi-commits] [lmi] master 742ee1a 3/6: Where strlen() semantics are wanted, use strlen(), Greg Chicares, 2018/06/18
- [lmi-commits] [lmi] master 274c964 5/6: Laconize, Greg Chicares, 2018/06/18