From 63b1d0c353ad8762c4eb5d7e494baf6e163ca1f7 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 12 Sep 2017 11:31:57 +0800 Subject: [PATCH] Rename some string conversion function to the common 'to_string' --- src/color.cc | 4 ++-- src/color.hh | 2 +- src/face_registry.cc | 7 ++----- src/json_ui.cc | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/color.cc b/src/color.cc index 19df9752..de422098 100644 --- a/src/color.cc +++ b/src/color.cc @@ -52,7 +52,7 @@ Color str_to_color(StringView color) return Color::Default; } -String color_to_str(Color color) +String to_string(Color color) { if (color.color == Color::RGB) { @@ -70,7 +70,7 @@ String color_to_str(Color color) String option_to_string(Color color) { - return color_to_str(color); + return to_string(color); } void option_from_string(StringView str, Color& color) diff --git a/src/color.hh b/src/color.hh index b4c75304..d8a2fcce 100644 --- a/src/color.hh +++ b/src/color.hh @@ -48,7 +48,7 @@ constexpr bool operator!=(Color lhs, Color rhs) } Color str_to_color(StringView color); -String color_to_str(Color color); +String to_string(Color color); String option_to_string(Color color); void option_from_string(StringView str, Color& color); diff --git a/src/face_registry.cc b/src/face_registry.cc index 0ae1ae46..192f9fda 100644 --- a/src/face_registry.cc +++ b/src/face_registry.cc @@ -42,7 +42,7 @@ static Face parse_face(StringView facedesc) return res; } -String attributes_to_str(Attribute attributes) +String to_string(Attribute attributes) { if (attributes == Attribute::Normal) return ""; @@ -67,10 +67,7 @@ String attributes_to_str(Attribute attributes) String to_string(Face face) { - return format("{},{}{}", - color_to_str(face.fg), - color_to_str(face.bg), - attributes_to_str(face.attributes)); + return format("{},{}{}", face.fg, face.bg, face.attributes); } Face FaceRegistry::operator[](const String& facedesc) diff --git a/src/json_ui.cc b/src/json_ui.cc index 8f4d4663..ca7d3109 100644 --- a/src/json_ui.cc +++ b/src/json_ui.cc @@ -68,7 +68,7 @@ String to_json(Color color) sprintf(buffer, R"("#%02x%02x%02x")", color.r, color.g, color.b); return buffer; } - return to_json(color_to_str(color)); + return to_json(to_string(color)); } String to_json(Attribute attributes)