mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
Introduce constants for clipboard option names
This commit is contained in:
@@ -2,6 +2,11 @@
|
||||
#include <text/utf8.h>
|
||||
#include <text/hexdump.h>
|
||||
|
||||
std::string const kClipboardOptionIndent = "indent";
|
||||
std::string const kClipboardOptionComplete = "complete";
|
||||
std::string const kClipboardOptionFragments = "fragments";
|
||||
std::string const kClipboardOptionColumnar = "columnar";
|
||||
|
||||
clipboard_t::entry_t::entry_t (std::string const& content, std::map<std::string, std::string> const& options) : _content(content), _options(options)
|
||||
{
|
||||
if(!utf8::is_valid(_content.begin(), _content.end()))
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
|
||||
#include <oak/misc.h>
|
||||
|
||||
extern std::string const kClipboardOptionIndent;
|
||||
extern std::string const kClipboardOptionComplete;
|
||||
extern std::string const kClipboardOptionFragments;
|
||||
extern std::string const kClipboardOptionColumnar;
|
||||
|
||||
struct PUBLIC clipboard_t
|
||||
{
|
||||
struct PUBLIC entry_t
|
||||
|
||||
@@ -293,10 +293,10 @@ namespace ng
|
||||
static std::map<std::string, std::string> create_find_options (std::string const& indent, bool complete, size_t fragments, bool columnar)
|
||||
{
|
||||
std::map<std::string, std::string> res;
|
||||
if(indent != NULL_STR) res["indent"] = indent;
|
||||
if(complete) res["complete"] = "1";
|
||||
if(fragments > 1) res["fragments"] = std::to_string(fragments);
|
||||
if(columnar) res["columnar"] = "1";
|
||||
if(indent != NULL_STR) res[kClipboardOptionIndent] = indent;
|
||||
if(complete) res[kClipboardOptionComplete] = "1";
|
||||
if(fragments > 1) res[kClipboardOptionFragments] = std::to_string(fragments);
|
||||
if(columnar) res[kClipboardOptionColumnar] = "1";
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -455,10 +455,10 @@ namespace ng
|
||||
std::map<std::string, std::string> options = entry->options();
|
||||
str.erase(text::convert_line_endings(str.begin(), str.end(), text::estimate_line_endings(str.begin(), str.end())), str.end());
|
||||
|
||||
std::string const& indent = options["indent"];
|
||||
bool const complete = options["complete"] == "1";
|
||||
size_t const fragments = strtol(options["fragments"].c_str(), nullptr, 10);
|
||||
bool const columnar = options["columnar"] == "1";
|
||||
std::string const& indent = options[kClipboardOptionIndent];
|
||||
bool const complete = options[kClipboardOptionComplete] == "1";
|
||||
size_t const fragments = strtol(options[kClipboardOptionFragments].c_str(), nullptr, 10);
|
||||
bool const columnar = options[kClipboardOptionColumnar] == "1";
|
||||
|
||||
if((selections.size() != 1 || selections.last().columnar) && (fragments > 1 || oak::contains(str.begin(), str.end(), '\n')))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user