Commit Graph

709 Commits

Author SHA1 Message Date
Alexandre Bury
8d1f0cc603
Require rustix/process when use-dev-tty is enabled (#906) 2024-08-01 20:12:05 +02:00
Timon
5d50d8da62
Minor upgrade to crossterm 0.28 (#898) 2024-07-31 19:41:00 +02:00
rustco
25e14782e3
Fix some comments (#899) 2024-07-31 18:56:39 +02:00
Tim Straubinger
33b4e37223
Fix duplicate bit masks for caps lock and num lock (#863) 2024-06-16 15:04:33 +02:00
illiteratewriter
61ff5ae1ce
docs: update docs for focus change event (#784) (#864)
* docs: update docs for focus change event (#784)

* docs: update example to include execute command

- add space between links
2024-06-16 15:00:25 +02:00
Heath Stewart
080f06494a
Improve color detection across platforms (#885)
Fixes #882 by improving `style::available_color_count()`:
- Checks ANSI support on Windows.
- Uses the COLORTERM environment variable and falls back to the TERM environment variable.
- Supports "xterm-24bit" and "truecolor" values which return `u16::MAX`.
2024-06-16 14:58:31 +02:00
Josh McKinney
fe440284bf
Use rustix instead of libc (additive only approach) (#892)
* use rustix instead of libc

* make rustix the default feature

* bump msrv to 1.63.0

* fix remaining libc issues

- use rustix version of sigwinch signal
- add a lifetime to FileDesc and replace FileDesc::Static to
  FileDesc::Borrowed. This made it necessary to either add a lifetime to
  the libc version of FileDesc or replace all the callers with multiple
  paths (libc, rustix). Changing FileDesc was more straightforward.
  There are no usages of FileDesc found in any repo on github, so this
  change should be reasonably safe.

* add changelog entry for rustix / filedesc change
2024-06-16 14:56:13 +02:00
Austin Schey
be8cb8ce8e
fix: remove extra command (#894) 2024-06-16 14:44:34 +02:00
Josh McKinney
fce58c879a
fix: broken build issues (#888)
Co-authored-by: gwenn <gtreguier@gmail.com>
2024-05-05 18:47:20 +02:00
Rein Fernhout
6d20946dfe
Mark alacritty as supporting kitty protocol (#851) 2024-05-03 19:32:04 +02:00
Martin von Zweigbergk
6fde55416b
Remove unsafe and unnecessary size argument from FileDesc::read() (#821)
The `size` argument to `FileDesc::read()` is not checked against the
length of the buffer, so `libc::read()` could end up writing past the
buffer if we passed a size that's too large. However, we always pass
exactly the size of the buffer, so that doesn't happen. Let's just
remove the argument since it's not currently needed, thereby removing
the risk of bugs if the function is used incorrectly by future
callers.

This came up in review of `unsafe` Rust code at my company.
2024-05-03 19:30:15 +02:00
linrongbin16
f54e937a33
Add tested platforms to documentation (#872) 2024-05-03 19:26:10 +02:00
ken
2545954076
Fix cargo clippy warning and error (#877) 2024-05-03 19:23:50 +02:00
Josh McKinney
39ef1e42ba
Implement Display for KeyCode and KeyModifiers (#862)
Partially addresses #792
* Implement Display for KeyCode and KeyModifiers
* Add demo for Display implementation
2024-05-03 19:23:07 +02:00
Josh McKinney
7efe19da28
perf: speed up SetColors by ~15-25% (#879)
The SetColors command was executing SetForegroundColor and then
SetBackgroundColor, which writes 2 extra characters per cell compared to
writing both colors in one command. This resulted in about 15-25% more
FPS (19->24 fps) on a fullscreen (171x51) app that writes every cell
with a different foreground and background color, compared to separately
using the SetForegroundColor and SetBackgroundColor commands (iTerm2, M2
Macbook Pro).

The app is the colors_rgb example in Ratatui, which writes every cell
with a different foreground and background color in a loop. The
CrosstermBackend was changed to use SetColors instead of
SetForegroundColor and SetBackgroundColor.
2024-05-03 18:53:06 +02:00
breno
99fe255f33
Update README getting started snippets (#859)
Theres no Result trait in crossterm
2024-01-28 10:59:41 +01:00
Kier Davis
0935196d5a
Add functions to allow constructing Attributes in a const context (#817)
Previously, the only ways to construct new `Attributes` values were
`Attributes::default()` or `Attributes::from(_)`, neither of can be
made `const fn` due to limitations of these standard library traits.
2024-01-06 13:03:59 +01:00
Przemek Pawlas
94fdd586e6
(De)serialize Reset color (#824) 2024-01-06 13:02:38 +01:00
Stephen Hunt
cd1780c2d8
Capture double click mouse events (#826)
When double clicking on Windows, the crossterm_winapi emits the first
click with `EventFlags::PressOrRelease` and the second click with
`EventFlags::DoubleClick`. Previously this code explicitly ignored mouse
events with `EventFlags::DoubleClick` because "double click not
supported by unix terminals." This change captures the double click and
surfaces them as normal click events.
2024-01-06 13:01:07 +01:00
Charles German
6d6bed9c2c
Update Cargo.toml snippets (#811)
The snippets show version 0.26, but the latest version is 0.27
2024-01-06 12:54:40 +01:00
Dheepak Krishnamurthy
b565646f27
Fix typo in CHANGELOG.md (#816) 2024-01-06 12:54:15 +01:00
Dheepak Krishnamurthy
a2b0e6a537
Fix typo in BeginSynchronizedUpdate docstring (#833) 2024-01-06 12:53:45 +01:00
Valerii Petryniak
0914f2d91e
Update README.md: fix typo (#832) 2024-01-06 12:53:21 +01:00
javaLux
7ef45a6991
Add MacOs monterey to tested terminals (#846) 2024-01-06 12:52:53 +01:00
Pedro Mendes
544ac19c41
Remove redundant docs and broken anchor (#845) 2024-01-06 12:52:00 +01:00
jumbledFox
dc09c6a057
Fix minor formatting mistake (#852) 2024-01-06 12:50:50 +01:00
Timon
08762b3ef4 Update CHANGELOG.md 2023-08-06 14:21:48 +02:00
Timon
9a6d740ed5 0.27.0 2023-08-06 14:20:33 +02:00
Timon
9fb2e0dafd
Update dependencies (#809) 2023-08-06 14:18:21 +02:00
Benjamin Grosse
8e254000c2
Fix format (#808) 2023-08-06 14:01:26 +02:00
Timon
e4ffda6439 Update CHANGELOG.md 2023-08-05 15:57:36 +02:00
Kevin Vigor
f3c0754bf5
Add style::force_color_output() API to override NO_COLOR. (#802) 2023-08-05 15:38:17 +02:00
Dave
00f7d06151
[testing] serial testing perserving terminal (#791)
This change does two things:
- add the serial_test crate to run selected tests serial rather
  than in parallel. This is done because they use global state
  so running them in parallel leads to race conditions and flaky
  results (sometimes they pass, sometimes they fail). Running
  them serialy avoids this flakiness.
- create a screen buffer within the test. This avoids changing
  the terminal (screen buffer) which is running the test. for
  example, a test that changes the terminal size to 20 x 20 can
  leave the developer running the test with a resized terminal.
  Creating a separate screen buffer for the test avoids this.
2023-08-05 15:36:42 +02:00
Robin Grönberg
55739aa786
Add support for scrolling left and right. (#788) 2023-08-05 15:35:43 +02:00
Wilfred Hughes
db443b08e8
Specify and document MSRV for 0.26 (#798)
As of 318f810a39, crossterm uses RFC
2795 implicit named arguments, which shipped in Rust 1.58.

Co-authored-by: Timon <timonpost@hotmail.nl>
2023-08-05 15:34:37 +02:00
Benjamin Grosse
10c54b0056
Add window_size() for unix (#790)
It is possible to render images in terminals with protocols such as Sixel,
iTerm2's, or Kitty's. For a basic sixel or iTerm2 image printing, it is
sufficient to print some escape sequence with the data, e.g. cat image just
works, the image is displayed and enough lines are scrolled.

But for more sophisticated usage of images, such as TUIs, it is necessary to
know exactly what area that image would cover, in terms of columns/rows of
characters. Then it would be possible to e.g. resize the image to a size that
fits a col/row area precisely, not overdraw the image area, accommodate layouts,
etc.

Thus, provide the window size in pixel width/height, in addition to cols/rows.

The windows implementation always returns a "not implemented" error. The
windows API exposes a font-size, but in logical units, not pixels.

This could be further extended to expose either "logical window size",
or "pixel font size" and "logical font size".
2023-08-05 15:34:27 +02:00
Peter Hebden
ff01914328
Parse hex colour codes in serde:🇩🇪:Deserialize (#801) 2023-08-05 15:25:59 +02:00
blt__
2cb2658180
Fix use statement in docs (#799) 2023-08-05 15:24:54 +02:00
Peter Hebden
2f232efad4
Add NixOS Kitty to tested terminals (#800) 2023-08-05 15:24:28 +02:00
Dheepak Krishnamurthy
eaa8b7567b
Fix typo in docs (#796) 2023-08-05 15:22:27 +02:00
Deathvenom
7183d65d6b
Update versions to 0.26 (Cargo.toml) (#804)
The Cargo.toml snippet lists the version as 0.23 while the latest one is 0.26, replaced the same
2023-08-05 15:22:17 +02:00
Peter Hebden
e2ddc1787a
Move key release event to breaking change (#805) 2023-08-05 15:22:00 +02:00
Remo Senekowitsch
1efdce7ef6
Link to latests docs in README (#785) 2023-06-12 19:06:45 +02:00
Kevin Vigor
2c534fc69e
Support NO_COLOR. (#782) 2023-06-12 19:06:11 +02:00
José Luis Cruz
dfc67e54c8
Fix interactive-demo (#783) 2023-04-23 12:41:00 +02:00
Timon
769b18151c Add comments to feature flags 2023-04-08 15:34:23 +02:00
Timon
b2cbd94853
Upgrade to bitflags 2 (#777) 2023-04-08 15:30:43 +02:00
gibbz00
a2c9350ff2
Unwrap crossterm::Result<T, ErrorKind> to std::io::Result. (#765) 2023-04-07 18:17:10 +02:00
Timon
41901c6382 Update lib.rs docs 2023-04-07 17:29:15 +02:00
lesleyrs
923aaf517b
Fix examples on windows (#775) 2023-04-07 17:10:56 +02:00