diff --git a/src/option_types.hh b/src/option_types.hh index a63a2512..6164de14 100644 --- a/src/option_types.hh +++ b/src/option_types.hh @@ -29,6 +29,8 @@ inline void option_from_string(const String& str, bool& opt) throw runtime_error("boolean values are either true, yes, false or no"); } +constexpr Codepoint list_separator = ';'; + template String option_to_string(const std::vector& opt) { @@ -37,7 +39,7 @@ String option_to_string(const std::vector& opt) { res += option_to_string(opt[i]); if (i != opt.size() - 1) - res += ','; + res += list_separator; } return res; } @@ -46,7 +48,7 @@ template void option_from_string(const String& str, std::vector& opt) { opt.clear(); - std::vector elems = split(str, ','); + std::vector elems = split(str, list_separator); for (auto& elem: elems) { T opt_elem; @@ -62,26 +64,21 @@ bool option_add(std::vector& opt, const std::vector& vec) return not vec.empty(); } +constexpr Codepoint tuple_separator = '|'; template struct TupleOptionDetail { static String to_string(const std::tuple& opt) { - return TupleOptionDetail::to_string(opt) + ":" + option_to_string(std::get(opt)); + return TupleOptionDetail::to_string(opt) + + tuple_separator + option_to_string(std::get(opt)); } - static void from_string(const String& str, std::tuple& opt) + static void from_string(const memoryview& elems, std::tuple& opt) { - auto it = str.begin(); - auto end = str.end(); - for (size_t i = 0; i < I; ++i) - it = std::find(it+1, end, ':'); - if (it == end) - throw runtime_error("not enough elements in tuple"); - - option_from_string(String{it+1, std::find(it+1, end, ':')}, std::get(opt)); - TupleOptionDetail::from_string(str, opt); + option_from_string(elems[I], std::get(opt)); + TupleOptionDetail::from_string(elems, opt); } }; @@ -93,9 +90,9 @@ struct TupleOptionDetail<0, Types...> return option_to_string(std::get<0>(opt)); } - static void from_string(const String& str, std::tuple& opt) + static void from_string(const memoryview& elems, std::tuple& opt) { - option_from_string(String{str.begin(), std::find(str.begin(), str.end(), ':')}, std::get<0>(opt)); + option_from_string(elems[0], std::get<0>(opt)); } }; @@ -108,7 +105,10 @@ String option_to_string(const std::tuple& opt) template void option_from_string(const String& str, std::tuple& opt) { - TupleOptionDetail::from_string(str, opt); + auto elems = split(str, tuple_separator); + if (elems.size() != sizeof...(Types)) + throw runtime_error("not enough elements in tuple"); + TupleOptionDetail::from_string(elems, opt); } template diff --git a/src/rc/clang.kak b/src/rc/clang.kak index 1c5e76c0..72577990 100644 --- a/src/rc/clang.kak +++ b/src/rc/clang.kak @@ -21,7 +21,7 @@ def clang-complete %{ rm -r $(dirname ${kak_opt_clang_filename}) completions="${kak_cursor_line}:${kak_cursor_column}@${kak_timestamp}" for cmp in ${output}; do - completions="${completions},${cmp}" + completions="${completions};${cmp}" done echo "eval -client $kak_client %[ echo completed; setb completions '${completions}' ]" | socat stdin UNIX-CONNECT:${kak_socket} ) >& /dev/null < /dev/null & diff --git a/src/rc/git-tools.kak b/src/rc/git-tools.kak index 3052a0a7..7f244a66 100644 --- a/src/rc/git-tools.kak +++ b/src/rc/git-tools.kak @@ -36,7 +36,7 @@ def git-blame %{ text="${sha:0:8} ${authors[$sha]}" flag="$line:black:$text" for (( i=1; $i < $count; i++ )); do - flag="$flag,$(($line+$i)):black:$text" + flag="$flag;$(($line+$i))|black|$text" done echo "setb -add -buffer $kak_bufname git_blame_flags %{${flag}}" | socat -u stdin UNIX-CONNECT:${kak_socket} }