From 8f91b297f1bf3399e0abc3e1de0c3ce1801c0580 Mon Sep 17 00:00:00 2001 From: "Loren M. Lang" Date: Tue, 16 Jan 2024 01:42:00 -0800 Subject: [PATCH 1/6] Create a basic Continuous Integration test Run a program test at the end. --- .github/workflows/ci.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..df78dae --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,24 @@ +name: TerminalImageViewer CI + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "*" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Install dependencies + run: sudo apt-get install -qy imagemagick + - name: Build + run: make -C src + - name: Install + run: sudo make -C src install + - name: Test + run: tiv /usr/share/pixmaps/debian-logo.png From 2b46a7a2272ccb07308d106988e90105dc6582a5 Mon Sep 17 00:00:00 2001 From: "Loren M. Lang" Date: Tue, 16 Jan 2024 01:55:04 -0800 Subject: [PATCH 2/6] Specifiy specific size and colors --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index df78dae..c86c18a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,4 +21,4 @@ jobs: - name: Install run: sudo make -C src install - name: Test - run: tiv /usr/share/pixmaps/debian-logo.png + run: tiv -w 80 -h 24 -2 /usr/share/pixmaps/debian-logo.png From ba7bafe092b373621bd398fa616bc4be921dd256 Mon Sep 17 00:00:00 2001 From: "Loren M. Lang" Date: Fri, 19 Jan 2024 11:15:19 -0800 Subject: [PATCH 3/6] Dropped install and don't restrict color palette during test --- .github/workflows/ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c86c18a..a798e4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,5 @@ jobs: run: sudo apt-get install -qy imagemagick - name: Build run: make -C src - - name: Install - run: sudo make -C src install - name: Test - run: tiv -w 80 -h 24 -2 /usr/share/pixmaps/debian-logo.png + run: ./src/tiv -w 80 -h 24 /usr/share/pixmaps/debian-logo.png From 1154264c54002695bd2a4f5e34f9d259155c29f7 Mon Sep 17 00:00:00 2001 From: Stefan Haustein Date: Wed, 24 Jan 2024 19:49:07 +0100 Subject: [PATCH 4/6] Clarify / clean up some comments --- src/tiv.cpp | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/src/tiv.cpp b/src/tiv.cpp index cef3516..4e2f783 100644 --- a/src/tiv.cpp +++ b/src/tiv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Aaron Liu + * Copyright (c) 2017-2023, Stefan Haustein, Aaron Liu * * This file is free software: you may copy, redistribute and/or modify it * under the terms of the GNU General Public License as published by the @@ -14,22 +14,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * This file incorporates work covered by the following copyright and - * permission notice: - * - * Copyright (c) 2017—2021, Stefan Haustein - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * This file used to be licensed under the Apache license. Older version + * under this license are available via the git history of this repository. */ #include @@ -71,9 +57,6 @@ #define EX_CONFIG 78 /* configuration error */ #endif -// using namespace std; // haha nope, bad style -// especially when we're also using the CImg namespace - // Implementation of flag representation for flags in the main() method constexpr int FLAG_FG = 1; constexpr int FLAG_BG = 2; @@ -82,15 +65,18 @@ constexpr int FLAG_24BIT = 8; // 24-bit color mode constexpr int FLAG_NOOPT = 16; // Only use the same half-block character constexpr int FLAG_TELETEXT = 32; // Use teletext characters -// Steps (@TODO: Figure out what exactly they represent) +// Color saturation value steps from 0 to 255 constexpr int COLOR_STEP_COUNT = 6; constexpr int COLOR_STEPS[COLOR_STEP_COUNT] = {0, 0x5f, 0x87, 0xaf, 0xd7, 0xff}; +// Grayscale saturation value steps from 0 to 255 constexpr int GRAYSCALE_STEP_COUNT = 24; constexpr int GRAYSCALE_STEPS[GRAYSCALE_STEP_COUNT] = { 0x08, 0x12, 0x1c, 0x26, 0x30, 0x3a, 0x44, 0x4e, 0x58, 0x62, 0x6c, 0x76, 0x80, 0x8a, 0x94, 0x9e, 0xa8, 0xb2, 0xbc, 0xc6, 0xd0, 0xda, 0xe4, 0xee}; +// An interleaved map of 4x8 bit character bitmaps (each hex digit represents a row) +// to the corresponding unicode character code point. constexpr unsigned int BITMAPS[] = { 0x00000000, 0x00a0, From 512b3dd91cd0cf3008bb5117883b7444d78e09d5 Mon Sep 17 00:00:00 2001 From: Stefan Haustein Date: Wed, 24 Jan 2024 19:55:40 +0100 Subject: [PATCH 5/6] Align license header with README.md --- src/tiv.cpp | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/tiv.cpp b/src/tiv.cpp index 4e2f783..50176a9 100644 --- a/src/tiv.cpp +++ b/src/tiv.cpp @@ -1,21 +1,33 @@ /* * Copyright (c) 2017-2023, Stefan Haustein, Aaron Liu * - * This file is free software: you may copy, redistribute and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. + * This file is free software: you may copy, redistribute and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. * - * This file is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * This file is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . * - * This file used to be licensed under the Apache license. Older version - * under this license are available via the git history of this repository. + * Alternatively, you may copy, redistribute and/or modify this file under + * the terms of the Apache License, version 2.0: + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include From bba4a692dba7248a8cff6f356bc0ddca2bed9896 Mon Sep 17 00:00:00 2001 From: Stefan Haustein Date: Wed, 24 Jan 2024 20:13:28 +0100 Subject: [PATCH 6/6] clarify comments some more --- src/tiv.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/tiv.cpp b/src/tiv.cpp index 50176a9..c63528f 100644 --- a/src/tiv.cpp +++ b/src/tiv.cpp @@ -40,14 +40,15 @@ #include #include -// CImg, the superior grafiks library +// This #define tells CImg that we use the library without any display options -- +// just for loading images. #define cimg_display 0 #include "CImg.h" -// First include for detecting console output size, -// everything else for exit codes #ifdef _POSIX_VERSION +// Console output size detection #include +// Exit codes #include #endif