lots of changes after a lot of time
rewrote some functions to use an accompanying function that returns a string; this prepares for splitting us into a library fixed weird bug caused by CImg update some endls have been replaced with \n slightly more consistent function naming more comments 1.3 part 1 out of ?
This commit is contained in:
commit
ac334fdfaa
2 changed files with 43 additions and 22 deletions
22
.github/workflows/ci.yml
vendored
Normal file
22
.github/workflows/ci.yml
vendored
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
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: Test
|
||||||
|
run: ./src/tiv -w 80 -h 24 /usr/share/pixmaps/debian-logo.png
|
23
src/tiv.cpp
23
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
|
* 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
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
@ -14,10 +14,8 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* This file incorporates work covered by the following copyright and
|
* Alternatively, you may copy, redistribute and/or modify this file under
|
||||||
* permission notice:
|
* the terms of the Apache License, version 2.0:
|
||||||
*
|
|
||||||
* Copyright (c) 2017—2021, Stefan Haustein
|
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -42,17 +40,18 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
// 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
|
#define cimg_display 0
|
||||||
#include "CImg.h"
|
#include "CImg.h"
|
||||||
// CImg defines its own min and max macros to compile, so we need to undef them
|
// CImg defines its own min and max macros to compile, so we need to undef them
|
||||||
#undef min
|
#undef min
|
||||||
#undef max
|
#undef max
|
||||||
|
|
||||||
// First include for detecting console output size,
|
|
||||||
// everything else for exit codes
|
|
||||||
#ifdef _POSIX_VERSION
|
#ifdef _POSIX_VERSION
|
||||||
|
// Console output size detection
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
// Exit codes
|
||||||
#include <sysexits.h>
|
#include <sysexits.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -74,9 +73,6 @@
|
||||||
#define EX_CONFIG 78 /* configuration error */
|
#define EX_CONFIG 78 /* configuration error */
|
||||||
#endif
|
#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
|
// Implementation of flag representation for flags in the main() method
|
||||||
constexpr int FLAG_FG = 1; // emit fg color
|
constexpr int FLAG_FG = 1; // emit fg color
|
||||||
constexpr int FLAG_BG = 2; // emit bg color
|
constexpr int FLAG_BG = 2; // emit bg color
|
||||||
|
@ -85,15 +81,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_NOOPT = 16; // Only use the same half-block character
|
||||||
constexpr int FLAG_TELETEXT = 32; // Use teletext characters
|
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_STEP_COUNT = 6;
|
||||||
constexpr int COLOR_STEPS[COLOR_STEP_COUNT] = {0, 0x5f, 0x87, 0xaf, 0xd7, 0xff};
|
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_STEP_COUNT = 24;
|
||||||
constexpr int GRAYSCALE_STEPS[GRAYSCALE_STEP_COUNT] = {
|
constexpr int GRAYSCALE_STEPS[GRAYSCALE_STEP_COUNT] = {
|
||||||
0x08, 0x12, 0x1c, 0x26, 0x30, 0x3a, 0x44, 0x4e, 0x58, 0x62, 0x6c, 0x76,
|
0x08, 0x12, 0x1c, 0x26, 0x30, 0x3a, 0x44, 0x4e, 0x58, 0x62, 0x6c, 0x76,
|
||||||
0x80, 0x8a, 0x94, 0x9e, 0xa8, 0xb2, 0xbc, 0xc6, 0xd0, 0xda, 0xe4, 0xee};
|
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[] = {
|
constexpr unsigned int BITMAPS[] = {
|
||||||
0x00000000, 0x00a0,
|
0x00000000, 0x00a0,
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue