Skip to content

Commit

Permalink
Proper PDCurses/Windows support and some other stuff
Browse files Browse the repository at this point in the history
* Added PDCurses support. Consequently, Windows is properly supported now
* Use map.find instead map.at when parsing command line options (because I was an idiot and forgot that try doesn't catch out of range exceptions)
* Fixed the options parser for asciiplay
* Updated README
  • Loading branch information
LeadRDRK committed Feb 9, 2021
1 parent 5e62aaf commit 84f0a15
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 15 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ make
```
## Windows
Using a Unix-like environment with MinGW-w64 is recommended. The procedure is
exactly the same as Linux as described above.
exactly the same as Linux as described above. As for the curses library, PDCurses
with wincon is recommended.
# Usage
Example: Encoding a video from *.png files with audio
```
asciienc -i path/to/frames_folder --ifmt png -fps 30 -a audio.ogg output.asv
```
Example: Play a video
```
asciiplay video.asv
```
More information can found by executing the programs with the --help option.

Please note that the user interface for asciiplay is incomplete and buggy. It can be disabled using the -disableui option.
# Demo
As usual, here's the classic [Bad Apple!!](https://youtu.be/C_qwSUhRv8U)
7 changes: 3 additions & 4 deletions src/asciienc/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,13 @@ Options::Options(int &argc, char** &argv)
break;
}

int optionType;
try {
optionType = optionsMap.at(option);
} catch (int e) {
auto it = optionsMap.find(option);
if (it == optionsMap.end()) {
std::cout << "Error: Invalid option: " << option << "\n\n";
bad = true;
break;
}
int optionType = it->second;

if (optionType >= INPUT && optionType <= OFMT) {
// options within this range requires an argument
Expand Down
2 changes: 1 addition & 1 deletion src/asciiplay/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ find_package(Curses REQUIRED)
add_executable(asciiplay ${SOURCES} ${HEADERS})
set_property(TARGET asciiplay PROPERTY CXX_STANDARD 17)
target_include_directories(asciiplay PRIVATE .. ${EXT_INCLUDE_DIRS} ${CURSES_INCLUDE_DIRS})
target_link_libraries(asciiplay PRIVATE Threads::Threads ${CMAKE_DL_LIBS} ${CURSES_LIBRARIES})
target_link_libraries(asciiplay PRIVATE Threads::Threads ${CMAKE_DL_LIBS} ${CURSES_LIBRARIES})
16 changes: 7 additions & 9 deletions src/asciiplay/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,17 @@ Options::Options(int &argc, char** &argv)
if (bad) break;
std::string option(argv[i]);

if (i == argc - 1) {
input = option;
break;
}

int optionType;
try {
optionType = optionsMap.at(option);
} catch (int e) {
auto it = optionsMap.find(option);
if (it == optionsMap.end()) {
if (i == argc - 1) {
input = option;
break;
}
std::cout << "Error: Invalid option: " << option << "\n\n";
bad = true;
break;
}
int optionType = it->second;

switch (optionType) {
case HELP:
Expand Down
3 changes: 3 additions & 0 deletions src/asciiplay/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ static char LOGO[1473] =
#include <chrono>
#include <iostream>

#define PDC_WIDE
#define PDC_FORCE_UTF8
#define PDC_NCMOUSE
#include <curses.h>

namespace chrono = std::chrono;
Expand Down

0 comments on commit 84f0a15

Please sign in to comment.