From ca97659f83eb7392abc340cf19c9f248bf967c75 Mon Sep 17 00:00:00 2001 From: Aaron Liu Date: Thu, 1 Feb 2024 18:30:28 -0500 Subject: [PATCH] redo 9969dd1 --- src/tiv.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/tiv.cpp b/src/tiv.cpp index ad7d8fd..7178fad 100644 --- a/src/tiv.cpp +++ b/src/tiv.cpp @@ -424,7 +424,7 @@ int best_index(int value, const int STEPS[], int count) { return result; } -void emit_color(const int &flags, int r, int g, int b) { +void printTermColor(const int &flags, int r, int g, int b) { r = clamp_byte(r); g = clamp_byte(g); b = clamp_byte(b); @@ -461,7 +461,7 @@ void emit_color(const int &flags, int r, int g, int b) { std::cout << (bg ? "\x1B[48;5;" : "\u001B[38;5;") << color_index << "m"; } -void emitCodepoint(int codepoint) { +void printCodepoint(int codepoint) { if (codepoint < 128) { std::cout << static_cast(codepoint); } else if (codepoint < 0x7ff) { @@ -481,7 +481,7 @@ void emitCodepoint(int codepoint) { } } -void emit_image(const cimg_library::CImg &image, +void printImage(const cimg_library::CImg &image, const int &flags) { GetPixelFunction get_pixel = [&](int x, int y, int channel) -> unsigned char { @@ -496,12 +496,12 @@ void emit_image(const cimg_library::CImg &image, ? createCharData(get_pixel, x, y, 0x2584, 0x0000ffff) : findCharData(get_pixel, x, y, flags); if (x == 0 || charData.bgColor != lastCharData.bgColor) - emit_color(flags | FLAG_BG, charData.bgColor[0], + printTermColor(flags | FLAG_BG, charData.bgColor[0], charData.bgColor[1], charData.bgColor[2]); if (x == 0 || charData.fgColor != lastCharData.fgColor) - emit_color(flags | FLAG_FG, charData.fgColor[0], + printTermColor(flags | FLAG_FG, charData.fgColor[0], charData.fgColor[1], charData.fgColor[2]); - emitCodepoint(charData.codePoint); + printCodepoint(charData.codePoint); lastCharData = charData; } std::cout << "\x1b[0m" << std::endl; @@ -549,7 +549,7 @@ cimg_library::CImg load_rgb_CImg(const char *const &filename) { } // Implements --help -void emit_usage() { +void printUsage() { std::cerr << R"( Terminal Image Viewer v1.2.1 usage: tiv [options] [...] @@ -586,7 +586,7 @@ int main(int argc, char *argv[]) { int ret = EX_OK; // The return code for the program if (argc <= 1) { - emit_usage(); + printUsage(); return EX_USAGE; } @@ -620,7 +620,7 @@ int main(int argc, char *argv[]) { } else if (arg == "--256" || arg == "-2" || arg == "-256") { flags |= FLAG_MODE_256; } else if (arg == "--help" || arg == "-help") { - emit_usage(); + printUsage(); } else if (arg == "-x") { flags |= FLAG_TELETEXT; } else if (arg[0] == '-') { @@ -692,7 +692,7 @@ int main(int argc, char *argv[]) { 5); } // the acutal magic which generates the output - emit_image(image, flags); + printImage(image, flags); } catch (cimg_library::CImgIOException &e) { std::cerr << "Error: '" << filename << "' has an unrecognized file format" << std::endl; @@ -732,7 +732,7 @@ int main(int argc, char *argv[]) { // Probably no image; ignore. } } - if (count) emit_image(image, flags); + if (count) printImage(image, flags); std::cout << sb << std::endl << std::endl; } }