Skip to content

Commit

Permalink
Housekeeping
Browse files Browse the repository at this point in the history
  • Loading branch information
a-n-t-h-o-n-y committed Feb 7, 2024
1 parent e9fc5a4 commit 9fb022a
Show file tree
Hide file tree
Showing 42 changed files with 1,816 additions and 1,014 deletions.
23 changes: 19 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,37 @@ project(escape LANGUAGES CXX)

# Escape Library
add_library(escape STATIC
include/esc/area.hpp
include/esc/brush.hpp
include/esc/color.hpp
include/esc/esc.hpp
include/esc/event.hpp
include/esc/glyph.hpp
include/esc/io.hpp
include/esc/key.hpp
include/esc/mouse.hpp
include/esc/point.hpp
include/esc/sequence.hpp
include/esc/terminal.hpp
include/esc/terminfo.hpp
include/esc/trait.hpp
include/esc/detail/any_of.hpp
include/esc/detail/console_file.hpp
include/esc/detail/debug.hpp
include/esc/detail/is_urxvt.hpp
include/esc/detail/mask.hpp
include/esc/detail/signals.hpp
include/esc/detail/transcode.hpp

src/io.cpp
src/terminfo.cpp
src/terminal.cpp
src/trait.cpp
src/sequence.cpp
src/point.cpp
src/mouse.cpp
src/detail/display.cpp
src/detail/debug.cpp
src/detail/is_urxvt.cpp
src/detail/print.cpp
src/detail/transcode.cpp
src/detail/traits_to_int_sequence.cpp
src/detail/console_file.cpp
src/detail/signals.cpp
)
Expand Down
51 changes: 30 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,47 @@

__Terminal Escape Sequence Library__

Consists mainly of functions returning escape sequence strings, that, when
written to stdout, will alter the appearance or functionality of the terminal
emulator.
This library provides support for generating terminal escape sequences. These
sequences, when written to `stdout`, enable control over terminal visual
presentation and behavior.

Also provides a read() function that returns an Event variant for keyboard,
mouse and window resize events.
## Features

This library tries to be as general as possible and work with as many terminals
as possible without relying on the terminfo database.
- **Dynamic Terminal Control**: Generate escape sequences for cursor movement, text formatting, color settings, and more.
- **Event Handling**: Includes a `read()` function to handle keyboard, mouse inputs, and window resize events, enhancing interactive applications.
- **Cross-Terminal Compatibility**: Designed to work across various terminals without relying on a terminfo database.

Please open an issue if you find any bugs.
## Dependencies

Note that not all terminals implement these features in the same way.
- [ICU Library](https://icu.unicode.org/): For Unicode support.

## Dependencies
## Example Code

- [ICU Library](https://icu.unicode.org/)
- [tools/termcaps.cpp](./tools/termcaps.cpp)
- [tests/glyph.test.cpp](./tests/glyph.test.cpp)

## Future Features
## Planned Enhancements

- Add `Terminal_focus_in` and `Terminal_focus_out` Events that are triggered on
`CSI I` and `CSI O` input sequences. Enabled by Focus Event Mouse 1004. Only
if most terminal emulators support this.
- **Focus Events**: Integrate `TerminalFocusIn` and `TerminalFocusOut` events
for focus tracking. Events are triggered on `CSI I` and `CSI O` input sequences,
enabled by Focus Event Mouse 1004. Dependent on widespread terminal emulator
support.
- **BELL Sequences**: Add BELL sequences to adjust alert frequency and duration.
- **MacOS Compatibility**: Ensure full support across MacOS terminals.
- **Sixel Graphics**: Explore incorporating Sixel graphics for advanced terminal
imaging, contingent on emulator compatibility.

- Add BELL modifier sequences for frequency and duration.
## Current Limitations

- Check MacOS support
- **Incompatible Terminals**: Known issues with `aterm` and `eterm`.
- **Mouse Input Handling**: In Konsole, mouse input is limited to `MouseMode::Drag`.

- Sixel graphics, but only if most terminal emulators support this.
## Contributing

## Known Issues
Feedback and contributions are highly appreciated. If you encounter any issues
or have suggestions for improvements, please open an issue on our repository.

- Does not work with: aterm, eterm
## Note

- Some terminal emulators(Konsole) mouse input is always in `MouseMode::Drag`.
Terminal features and support vary significantly across emulators. It's
recommended to test functionality in your target environments.
25 changes: 6 additions & 19 deletions include/esc/area.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,15 @@

namespace esc {

/// Holds a width and height as `int`s.
/**
* Represents a rectangular area with a width and height.
*/
struct Area {
int width;
int height;
};

/// Compares the dimension values, not calculated areas.
auto constexpr operator==(Area const& x, Area const& y) -> bool
{
return x.width == y.width && x.height == y.height;
}

/// Compares the dimension values, not calculated areas.
auto constexpr operator!=(Area const& x, Area const& y) -> bool
{
return !(x == y);
}

/// Compares calculated area values, not the individual dimensions.
auto constexpr operator<(Area const& x, Area const& y) -> bool
{
return (x.width * x.height) < (y.width * y.height);
}
auto constexpr operator==(Area const& other) const -> bool = default;
auto constexpr operator!=(Area const& other) const -> bool = default;
};

} // namespace esc
9 changes: 6 additions & 3 deletions include/esc/brush.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#pragma once

#include <esc/color.hpp>
#include <esc/default_color.hpp>
#include <esc/trait.hpp>

namespace esc {

/// Convenience type to hold visual aspects of the terminal display.
/** use set_brush() */
/**
* Represents characteristics of the terminal display for text.
*
* @details An escape sequence can be generated from this type using
* escape(Brush) in sequence.hpp
*/
struct Brush {
Color background = DefaultColor{};
Color foreground = DefaultColor{};
Expand Down
Loading

0 comments on commit 9fb022a

Please sign in to comment.