Coder Social home page Coder Social logo

fltrdr's Introduction

Fltrdr

A TUI text reader for the terminal.

fltrdr

Click the above gif to view a video of Fltrdr in action.

Contents

About

Fltrdr, or flat-reader, is an interactive text reader for the terminal. It is flat in the sense that the reader is word-based. It creates a horizontal stream of words by ignoring all newline characters and removing sequential whitespace. Its purpose is to facilitate reading, scanning, and searching text. The program has a play mode that moves the reader forward one word at a time, along with a configurable words per minute (WPM) setting. It can be used to read text from either a file or stdin.

Features

  • word-based text reader
  • vi inspired key-bindings
  • read UTF-8 encoded text from a file or stdin
  • play mode with variable speed controlled through WPM
  • in play mode, longer pauses occur on words that end in punctuation
  • focus point to align the current word
  • focus point tries to be smart about its placement, ignoring any surrounding punctuation or plurality
  • search forwards and backwards using regular expressions
  • command prompt to interact with the program
  • store your settings in a configuration file
  • choose how many words are shown at a time
  • colours can be customized
  • chars/symbols can be customized
  • show/hide parts of the interface
  • mouse support for play/pause and scrolling text
  • history file for command prompt inputs
  • history file for search prompt inputs
  • fuzzy search prompt input history based on current prompt input
  • load and save reader state to continue where you last left off

Usage

View the usage and help output with the --help or -h flag. The help output contains the documentation for the key bindings and commands for customization.

Terminal Compatibility

This program uses raw terminal control sequences to manipulate the terminal, such as moving the cursor, styling the output text, and clearing the screen. Although some of the control sequences used may not work as intended on all terminals, they should work fine on any modern terminal emulator.

Pre-Build

This section describes what environments this program may run on, any prior requirements or dependencies needed, and any third party libraries used.

Important

Any shell commands using relative paths are expected to be executed in the root directory of this repository.

Dependencies

  • C++17 compiler/library
  • CMake >= 3.8
  • ICU >= 62.1
  • OpenSSL >= 1.1.0

Linked Libraries

  • stdc++fs (libstdc++fs) included in the C++17 Standard Library
  • crypto (libcrypto) part of the OpenSSL Library
  • icuuc (libicuuc) part of the ICU library
  • icui18n (libicui18n) part of the ICU library

Included Libraries

  • parg: for parsing CLI args, included as ./src/ob/parg.hh

Environment

  • Linux (supported)
  • BSD (supported)
  • macOS (supported)

macOS

Using a new version of gcc or llvm is required, as the default Apple llvm compiler does not support C++17 Standard Library features such as std::filesystem.

A new compiler can be installed through a third-party package manager such as Brew. Assuming you have Brew already installed, the following commands should install the latest gcc.

brew install gcc
brew link gcc

The following line will then need to be appended to the CMakeLists.txt file. Replace the placeholder <path-to-g++> with the canonical path to the new g++ compiler binary.

set (CMAKE_CXX_COMPILER <path-to-g++>)

Build

The following shell command will build the project in release mode:

./build.sh

To build in debug mode, run the script with the --debug flag.

Install

The following shell command will install the project in release mode:

./install.sh

To install in debug mode, run the script with the --debug flag.

Configuration

Base Config Directory (BASE): ${HOME}/.fltrdr
State Directory: BASE/state
History Directory: BASE/history
Config File: BASE/config
State Files: BASE/state/<content-id>
Search History File: BASE/history/search
Command History File: BASE/history/command

Use --config=<file> to override the default config file.
Use --config-base=<dir> to override the default base config directory.

The base config directory and config file must be created by the user. The config file in the base config directory must be named config. It is a plain text file that can contain any of the commands listed in the Commands section of the --help output. Each command must be on its own line. Lines that begin with the # character are treated as comments.

If you want to permanently use a different base config directory, such as ~/.config/fltrdr, add the following line to your shell profile:

alias fltrdr="fltrdr --config-base ~/.config/fltrdr"

The following shell commands will create the base config directory in the default location and copy over the example config file:

mkdir -pv ~/.fltrdr
cp -uv ./config/default ~/.fltrdr/config

Several config file examples can be found in the ./config directory.

License

This project is licensed under the MIT License.

Copyright (c) 2019 Brett Robinson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

fltrdr's People

Contributors

joseprrm avatar octobanana avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

fltrdr's Issues

Incompatible with lower version Macos(High Sierra)

/tmp/fltrdr/./src/ob/timer.hh:112:25: error: call to unavailable member function 'value': introduced in macOS 10.14
auto const t = pstr.value();
~~~~~^~~~~
/usr/local/Cellar/llvm/8.0.0/bin/../include/c++/v1/optional:938:33: note: candidate function has been explicitly made unavailable
constexpr value_type const& value() const&
^
/usr/local/Cellar/llvm/8.0.0/bin/../include/c++/v1/optional:947:27: note: candidate function not viable: 'this' argument has type 'const
std::__1::optional<std::__1::vector<std::__1::basic_string, std::__1::allocator<std::__1::basic_string > > >', but method is not marked const
constexpr value_type& value() &
^
/usr/local/Cellar/llvm/8.0.0/bin/../include/c++/v1/optional:956:28: note: candidate function not viable: 'this' argument has type 'const
std::__1::optional<std::__1::vector<std::__1::basic_string, std::__1::allocator<std::__1::basic_string > > >', but method is not marked const
constexpr value_type&& value() &&
^
/usr/local/Cellar/llvm/8.0.0/bin/../include/c++/v1/optional:965:34: note: candidate function not viable: no known conversion from 'const optional<...>' to 'const optional<...>' for
object argument
constexpr value_type const&& value() const&&
^

Fedora 31: Build error

Hi

I'm here once again to ask your assistance! I really like this project and would like to use this on fedora. I think I installed all the necessary packages.

  • icu
  • gcc
  • cmake
    Relevant errors

-- Build files have been written to: /home/ew/Documents/Proj/fltrdr/build/release
[ 14%] Building CXX object CMakeFiles/fltrdr.dir/src/main.cc.o
In file included from /home/ew/Documents/Proj/fltrdr/./src/fltrdr/fltrdr.hh:5,
                 from /home/ew/Documents/Proj/fltrdr/src/fltrdr/tui.hh:4,
                 from /home/ew/Documents/Proj/fltrdr/src/main.cc:7:
/home/ew/Documents/Proj/fltrdr/./src/ob/text.hh:6:10: fatal error: unicode/coll.h: No such file or directory
    6 | #include <unicode/coll.h>
      |          ^~~~~~~~~~~~~~~~

Add Unicode text support

Using Linux, I tried in different terminal emulators and all the accented characters I tested (éèàçôîû) show up wrong.

Error: could not open stdin with docker

I'm trying to build this into a Docker image but can't get stdin to work. It's very likely that I'm missing something Docker specific, but I'm not sure.

The error I get is: Error: could not open stdin using the following Dockerfile

RUN apk add --no-cache bash cmake make g++
WORKDIR /app
COPY CMakeLists.txt build.sh env.sh /app/
COPY src /app/src/
RUN ./build.sh

FROM alpine
RUN apk add --no-cache libstdc++
COPY --from=build /app/build/release/fltrdr /usr/bin/
ENTRYPOINT ["/usr/bin/fltrdr"]

Cannot rebind keys

Keys currently cannot be rebound.
HJKL is awkward for some non-standard/non-us keyboard layouts.

As fltrdr already exposes most if not all of the necessary commands to fit the functionality of the existing keybinds, I'd suggest a format in the config something like:

bind {key} {command} {args}

src/ob/string.hh:7:20 not found

Hey, I liked to try out your project but i'm getting the following error while trying to build or install:

[...]/fltrdr/./src/ob/string.hh:7:20: fatal error: optional: No such file or directory compilation terminated. CMakeFiles/fltrdr.dir/build.make:62: recipe for target 'CMakeFiles/fltrdr.dir/src/main.cc.o' failed make[2]: *** [CMakeFiles/fltrdr.dir/src/main.cc.o] Error 1 CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/fltrdr.dir/all' failed make[1]: *** [CMakeFiles/fltrdr.dir/all] Error 2 Makefile:129: recipe for target 'all' failed make: *** [all] Error 2
i install your parg lib, libstdc++6 and have cmake 3.14
ubuntu 16.04..

(Edit: same for peaclock)

Clarify Text Styles

Looking at the output of --help, it is difficult to discern what the various text style values (text, text-primary, text-secondary, text-highlight, etc) refer to.

When I first launched fltrdr on a text file I found the behaviour of highlighting the character under the cursor to be distracting. I wanted to highlight the whole word. Through trial and error I discovered that the property I wanted was text-primary, but it would have been helpful if the documentation was more specific on this point.

Ubuntu 18.04 Build Error

Setting Environment Variables

Building fltrdr in release mode

Compiling fltrdr
CMAKE_BUILD_TYPE is release
-- Configuring done
-- Generating done
-- Build files have been written to: /home/andrew/fltrdr/build/release
[ 16%] Building CXX object CMakeFiles/fltrdr.dir/src/fltrdr/tui.cc.o
clang: warning: argument unused during compilation: '-s' [-Wunused-command-line-argument]
/home/<user>/fltrdr/src/fltrdr/tui.cc:27:10: fatal error: 'filesystem' file not found
#include <filesystem>
         ^~~~~~~~~~~~
1 error generated.
CMakeFiles/fltrdr.dir/build.make:110: recipe for target 'CMakeFiles/fltrdr.dir/src/fltrdr/tui.cc.o' failed
make[2]: *** [CMakeFiles/fltrdr.dir/src/fltrdr/tui.cc.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/fltrdr.dir/all' failed
make[1]: *** [CMakeFiles/fltrdr.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

real	0m0.887s
user	0m0.815s
sys	0m0.053s

I get this error, I have been unable to resolve it. I also tried installing clang and using it as described in #3 (despite it being about MacOS). Probably I'm just missing something obvious.

Would it be hard to pipe a webpage to fltrdr?

Perhaps I'm the only one interested in that, but I wonder if it would be feasible to make fltrdr fetch the content of a webpage (with 0 depth on links of course) or even a div (if there are anchor URL available) with fltrdr <url>? Perhaps that is already doable with some other UNIX commands to fetch the text content and pipe it to fltrdr with command <url> | fltrdr?

I wonder if lynx and readability-cli could be used for that.

Odd Whitespace

I'm seeing fltrdr insert odd whitespace in some files. So far it seems to be limited to URLs. For example, see the screenshot reading the README.md for this project:

img-2019-02-19-203543

I am running v0.1.0 (18.02.2019).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.