From 7471417091db50e1103814ff5c51d3ff1e90427b Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 30 May 2018 10:05:01 -0700 Subject: [PATCH] modules/console: Add compose copy cmd. --- modules/console.cc | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/modules/console.cc b/modules/console.cc index 126e70088..8208d5792 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -2644,6 +2644,45 @@ console_cmd__compose__final(opt &out, const string_view &line) return true; } +bool +console_cmd__compose__copy(opt &out, const string_view &line) +{ + const params param{line, " ", + { + "srcid", "[dstid]" + }}; + + const auto &srcid + { + param.at(0) + }; + + const auto &dstid + { + param.at(1, compose.size()) + }; + + const auto &src + { + compose.at(srcid) + }; + + if(compose.size() < dstid) + throw error + { + "Cannot compose position %d without composing %d first", dstid, compose.size() + }; + + if(compose.size() == dstid) + { + compose.emplace_back(src); + return true; + } + + compose.at(dstid) = src; + return true; +} + bool console_cmd__compose__clear(opt &out, const string_view &line) {