Use ',' instead of '|' as tuple option fields separators

This commit is contained in:
Maxime Coste 2014-10-06 19:32:25 +01:00
parent 17d591b61c
commit 008ba2cbab
2 changed files with 10 additions and 9 deletions

View File

@ -63,9 +63,10 @@ def -shell-params \
if (line == "") { return; }
text=substr(sha,1,8) " " dates[sha] " " authors[sha]
gsub(":", "\\:", text)
flag=line "|black|" text
gsub(",", "\\,", text)
flag=line ",black," text
for ( i=1; i < count; i++ ) {
flag=flag ":" line+i "|black|" text
flag=flag ":" line+i ",black," text
}
cmd = "kak -p " ENVIRON["kak_session"]
print "set -add buffer=" ENVIRON["kak_bufname"] " git_blame_flags %{" flag "}" | cmd
@ -90,7 +91,7 @@ def -shell-params \
git diff -U0 $kak_buffile | awk -e '
BEGIN {
line=0
flags="0|red|."
flags="0,red,."
}
/^---.*/ {}
/^@@ -[0-9]+(,[0-9]+)? \+[0-9]+(,[0-9]+)? @@.*/ {
@ -101,10 +102,10 @@ def -shell-params \
}
}
/^\+/ {
flags=flags ":" line "|green|+"
flags=flags ":" line ",green,+"
line++
}
/^\-/ { flags=flags ":" line "|red|-" }
/^\-/ { flags=flags ":" line ",red,-" }
END { print "set buffer git_diff_flags ", flags }
'
}

View File

@ -99,7 +99,7 @@ bool option_add(std::unordered_set<T>& opt, const std::unordered_set<T>& set)
return not set.empty();
}
constexpr Codepoint tuple_separator = '|';
constexpr Codepoint tuple_separator = ',';
template<size_t I, typename... Types>
struct TupleOptionDetail
@ -175,9 +175,9 @@ bool option_add(T&, const T&)
template<typename EffectiveType, typename LineType, typename ColumnType>
inline void option_from_string(const String& str, LineAndColumn<EffectiveType, LineType, ColumnType>& opt)
{
auto vals = split(str, '|');
auto vals = split(str, tuple_separator);
if (vals.size() != 2)
throw runtime_error("expected <line>|<column>");
throw runtime_error("expected <line>"_str + tuple_separator + "<column>");
opt.line = str_to_int(vals[0]);
opt.column = str_to_int(vals[1]);
}
@ -185,7 +185,7 @@ inline void option_from_string(const String& str, LineAndColumn<EffectiveType, L
template<typename EffectiveType, typename LineType, typename ColumnType>
inline String option_to_string(const LineAndColumn<EffectiveType, LineType, ColumnType>& opt)
{
return to_string(opt.line) + '|' + to_string(opt.column);
return to_string(opt.line) + tuple_separator + to_string(opt.column);
}
enum YesNoAsk