Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[profile.default]
slow-timeout = { period = "3s", terminate-after = 2 }
slow-timeout = { period = "5s", terminate-after = 3 }
8 changes: 8 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
bin: tattoy
target: ${{ matrix.target }}
# I think we need to use this so that AUR updates don't fail with SHA sum mismtatches.
# archive: $bin-$tag-$target
locked: true
tar: unix
zip: windows
Expand Down Expand Up @@ -167,9 +169,15 @@ jobs:
permissions:
contents: read
steps:
- name: Write release version
run: |
TATTOY_VERSION=${GITHUB_REF_NAME#tattoy-v}
echo Tattoy version: $TATTOY_VERSION
echo "TATTOY_VERSION=$TATTOY_VERSION" >> $GITHUB_ENV
- name: Bump formula
uses: mislav/[email protected]
with:
tag-name: ${{ env.TATTOY_VERSION }}
homebrew-tap: tattoy-org/homebrew-tap
formula-name: tattoy
formula-path: tattoy.rb
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ env:
CARGO_TERM_COLOR: always
RUST_VERSION: 1.87.0
RUST_BACKTRACE: 1
RUST_LOG: "trace,tattoy_wezterm_term=off"

jobs:
build-test:
Expand Down Expand Up @@ -71,7 +72,7 @@ jobs:
--no-fail-fast --retries 2
- name: Output e2e test logs (on failure)
if: failure()
run: cat crates/tests/tattoy.log
run: cat crates/tests/tests.log

lints:
name: "Lints 💅"
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ tracing = "0.1.40"
tracing-subscriber = {version = "0.3.18", features = ["env-filter"]}

[workspace.dependencies.shadow-terminal]
version = "0.2.2"
version = "0.2.3"
# path = "../shadow-terminal/shadow-terminal/"

# Canonical lints for whole crate
Expand Down
1 change: 1 addition & 0 deletions crates/tattoy/default_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ path = "shaders/cursors/smear_fade.glsl"
# by default we set the cursor size to 0.0 to avoid this oversizing. However of course, not
# all cursor shaders will have this problem, so it may be useful to play with this value.
cursor_scale = 0.0
# NB: The global `frame_rate` setting can also have a significant affect on the animated cursor.

[bg_command]
enabled = false
Expand Down
4 changes: 2 additions & 2 deletions crates/tattoy/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ async fn setup(state: &std::sync::Arc<SharedState>) -> Result<CliArgs> {
// true color terminal anyway.
std::env::set_var("COLORTERM", "truecolor");

tracing::info!("Starting Tattoy");
tracing::info!("Starting Tattoy v{}", env!("CARGO_PKG_VERSION"));
tracing::debug!("Loaded config: {:?}", state.config.read().await);

let tty_size = crate::renderer::Renderer::get_users_tty_size()?;
Expand Down Expand Up @@ -304,7 +304,7 @@ async fn setup_logging(cli_args: CliArgs, state: &std::sync::Arc<SharedState>) -
// very noisy and most of it is just for the Tokio console, which aren't needed
// anyway as they're parsed internally.
tracing_subscriber::EnvFilter::builder()
.with_default_directive("error".parse()?)
.with_default_directive("warn".parse()?)
.from_env_lossy()
} else {
tracing_subscriber::EnvFilter::builder()
Expand Down
9 changes: 8 additions & 1 deletion crates/tattoy/src/tattoys/gpu/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,16 @@ impl GPU {
}

/// Align a buffer or texture dimension to a consistent multiple.
#[expect(
clippy::unwrap_used,
reason = "
`checked_div()` only returns `None` when the right-hand side is 0, which is clearly
impossible here.
"
)]
const fn align_dimension(number: u32) -> u32 {
let multiple = 256;
number.div_ceil(multiple) - 1 + multiple
(number.checked_div(multiple).unwrap() * multiple) + multiple
}

/// Create the bind group layout that defines where the various shader data is located.
Expand Down
27 changes: 17 additions & 10 deletions crates/tattoy/src/tattoys/gpu/shaderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,22 @@ pub(crate) trait Shaderer: Sized {
Ok(())
}

/// Update the cursor state ready for the next render.
async fn update_cursor(&mut self) -> Result<()> {
let cursor_position = self.tattoy().screen.surface.cursor_position();
let cursor_colour = self.get_cursor_colour(cursor_position.0, cursor_position.1)?;

let cursor_scale = self.get_cursor_scale().await;
self.gpu_mut().update_cursor(
cursor_position.0.try_into()?,
cursor_position.1.try_into()?,
cursor_colour,
cursor_scale,
);

Ok(())
}

/// Upload the TTY content as coloured pixels.
async fn upload_tty_as_pixels(&mut self) -> Result<()> {
let is_upload_tty_as_pixels = self.is_upload_tty_as_pixels().await;
Expand Down Expand Up @@ -210,16 +226,7 @@ pub(crate) trait Shaderer: Sized {
}
}

let cursor_position = self.tattoy().screen.surface.cursor_position();
let cursor_colour = self.get_cursor_colour(cursor_position.0, cursor_position.1)?;

let cursor_scale = self.get_cursor_scale().await;
self.gpu_mut().update_cursor(
cursor_position.0.try_into()?,
cursor_position.1.try_into()?,
cursor_colour,
cursor_scale,
);
self.update_cursor().await?;

self.tattoy_mut().initialise_surface();
self.tattoy_mut().opacity = self.get_opacity().await;
Expand Down
7 changes: 4 additions & 3 deletions crates/tattoy/src/tattoys/tattoyer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ impl Tattoyer {
output_channel: tokio::sync::mpsc::Sender<crate::run::FrameUpdate>,
) -> Self {
let tty_size = state.get_tty_size().await;
let target_frame_rate = state.config.read().await.frame_rate;
Self {
id: id.clone(),
layer,
Expand All @@ -53,7 +54,7 @@ impl Tattoyer {
height: tty_size.height,
scrollback: shadow_terminal::output::native::CompleteScrollback::default(),
screen: shadow_terminal::output::native::CompleteScreen::default(),
target_frame_rate: 30,
target_frame_rate,
last_frame_tick: tokio::time::Instant::now(),
last_scroll_position: 0,
}
Expand All @@ -76,13 +77,13 @@ impl Tattoyer {
self.height = height;
}

/// Handle commpm protocol messages, like resizing and new output from the underlying terminal.
/// Handle commom protocol messages, like resizing and new output from the underlying terminal.
pub(crate) fn handle_common_protocol_messages(
&mut self,
message: crate::run::Protocol,
) -> Result<()> {
tracing::trace!(
"'{}' tattoy recevied protocol message: {message:?}",
"'{}' tattoy received protocol message: {message:?}",
self.id
);

Expand Down
17 changes: 13 additions & 4 deletions crates/tattoy/src/terminal_proxy/input_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,25 @@ impl crate::terminal_proxy::proxy::Proxy {
return Ok(());
}

self.forward_input_to_pty(input).await
self.forward_input_to_pty(input.to_owned()).await
}

/// Forward raw input bytes to the underlying PTY.
async fn forward_input_to_pty(&self, input: &crate::raw_input::ParsedInput) -> Result<()> {
async fn forward_input_to_pty(&self, input: crate::raw_input::ParsedInput) -> Result<()> {
// If the input is from an OSC paste event, then only forward the contents of the paste,
// and not the surrounding OSC codes.
let bytes = if let termwiz::input::InputEvent::Paste(string) = input.event {
string.into_bytes()
} else {
input.bytes
};

tracing::trace!(
"Terminal proxy received input bytes: {}",
String::from_utf8_lossy(&input.bytes)
String::from_utf8_lossy(&bytes)
);
for chunk in input.bytes.chunks(128) {

for chunk in bytes.chunks(128) {
let mut buffer: crate::raw_input::BytesFromSTDIN = [0; 128];
for (i, chunk_byte) in chunk.iter().enumerate() {
let buffer_byte = buffer.get_mut(i).context("Couldn't get byte from buffer")?;
Expand Down
14 changes: 8 additions & 6 deletions crates/tests/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async fn basic_interactivity() {

crate::utils::assert_random_walker_moves(&mut tattoy).await;

tattoy.send_command("echo $((1+1))").unwrap();
tattoy.send_command_with_osc_paste("echo $((1+1))").unwrap();
tattoy.wait_for_string("2", None).await.unwrap();

crate::utils::assert_random_walker_moves(&mut tattoy).await;
Expand Down Expand Up @@ -112,7 +112,7 @@ async fn scrolling() {

let (mut tattoy, _) = crate::utils::start_tattoy(None).await;
tattoy
.send_command("cat resources/LOREM_IPSUM.txt")
.send_command_with_osc_paste("cat resources/LOREM_IPSUM.txt")
.unwrap();
assert_scrolling_off(&mut tattoy).await;

Expand All @@ -136,7 +136,7 @@ async fn palette_to_true_colour() {
let (mut tattoy, _) = crate::utils::start_tattoy(None).await;

tattoy
.send_command("echo -e \"\\033[0;31m$((1000-1))\\033[m\"")
.send_command_with_osc_paste("echo -e \"\\033[0;31m$((1000-1))\\033[m\"")
.unwrap();
tattoy.wait_for_string("999", None).await.unwrap();

Expand All @@ -157,7 +157,7 @@ async fn minimap() {
let size = tattoy.shadow_terminal.terminal.get_size();

tattoy
.send_command("cat resources/LOREM_IPSUM.txt")
.send_command_with_osc_paste("cat resources/LOREM_IPSUM.txt")
.unwrap();
tattoy.wait_for_string("nulla", None).await.unwrap();
tattoy
Expand Down Expand Up @@ -218,7 +218,7 @@ async fn plugins() {
conf_file.write_all(config.as_bytes()).unwrap();

let (mut tattoy, _) = crate::utils::start_tattoy(Some(conf_dir.to_string_lossy().into())).await;
tattoy.send_command("ls").unwrap();
tattoy.send_command_with_osc_paste("ls").unwrap();
let size = tattoy.shadow_terminal.terminal.get_size();
let bottom = size.rows - 1;
let right = size.cols - 1;
Expand Down Expand Up @@ -305,9 +305,11 @@ async fn auto_text_contrast() {
bg.relative_contrast(fg)
}

crate::utils::setup_logging();

let (mut tattoy, _) = crate::utils::start_tattoy(None).await;
tattoy
.send_command("resources/print_low_contrast_samples.sh")
.send_command_with_osc_paste("resources/print_low_contrast_samples.sh")
.unwrap();
tattoy.wait_for_string("middle", None).await.unwrap();
tattoy.wait_for_string("dark", None).await.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion scripts/aur/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license=("MIT")
arch=("x86_64")
provides=("tattoy")
conflicts=("tattoy")
source=("https://github.com/tattoy-org/tattoy/releases/download/tattoy-v$pkgver/tattoy-x86_64-unknown-linux-gnu.tar.gz")
source=(tattoy-v$pkgver.tar.gz::"https://github.com/tattoy-org/tattoy/releases/download/tattoy-v$pkgver/tattoy-x86_64-unknown-linux-gnu.tar.gz")
sha256sums=("SKIP")

package() {
Expand Down
Loading