Skip to content

Commit

Permalink
sixel render data
Browse files Browse the repository at this point in the history
  • Loading branch information
raphamorim committed Dec 6, 2023
1 parent 0f53181 commit 7c049b5
Show file tree
Hide file tree
Showing 11 changed files with 254 additions and 44 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
deploy:
runs-on: ubuntu-latest
Expand All @@ -42,7 +45,7 @@ jobs:
run: make docs-build

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
uses: peaceiris/actions-gh-pages@v3.9.3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/build
40 changes: 20 additions & 20 deletions .github/workflows/canary.yml → .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
name: Release Canary
name: Nightly

on:
workflow_run:
workflows: ['Test']
types:
- completed
workflow_dispatch:
schedule:
# 01:00 every day
- cron: '0 1 * * *'

env:
CARGO_TERM_COLOR: always
GITHUB_REPOSITORY: raphamorim/rio
RUST_BACKTRACE: full
RUSTFLAGS: '-C link-arg=-s'
CANARY_TAG: canary
NIGHTLY_TAG: nightly
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
Expand Down Expand Up @@ -44,7 +44,7 @@ jobs:
echo "One or more *.rs file(s) or any file in the static folder but not in the docs folder has changed."
echo "List all the files that have changed: ${{ steps.changed-files-excluded.outputs.all_changed_files }}"
- name: Delete old canary release
- name: Delete old nightly release
if: steps.changed-files-excluded.outputs.any_changed == 'true'
uses: dev-drprasad/[email protected]
with:
Expand All @@ -57,15 +57,15 @@ jobs:
if: steps.changed-files-excluded.outputs.any_changed == 'true'
uses: mathieudutour/[email protected]
with:
custom_tag: 'canary'
custom_tag: ${{ env.NIGHTLY_TAG }}
tag_prefix: ''
github_token: ${{ secrets.GITHUB_TOKEN }}

- id: status
if: steps.changed-files-excluded.outputs.any_changed == 'true'
run: echo "created=true" >> "$GITHUB_OUTPUT"

canary-release-macos:
nightly-release-macos:
needs: create_tag
if: ${{ needs.create_tag.outputs.created == 'true' }}
runs-on: macos-11.0
Expand All @@ -90,19 +90,19 @@ jobs:
- name: make release-macos
run: make release-macos

- name: Release canary
- name: Release nightly
uses: softprops/action-gh-release@v1
with:
name: Canary - ${{ github.sha }}
tag_name: ${{ env.CANARY_TAG }}
name: Nightly - ${{ github.sha }}
tag_name: ${{ env.NIGHTLY_TAG }}
prerelease: true
append_body: true
token: ${{ secrets.GITHUB_TOKEN }}
files: |
release/macos-rio.zip
LICENSE
canary-release-deb:
nightly-release-deb:
needs: create_tag
if: ${{ needs.create_tag.outputs.created == 'true' }}
runs-on: ubuntu-latest
Expand All @@ -128,19 +128,19 @@ jobs:
- run: make release-debian-x11
- run: make release-debian-wayland

- name: Release canary
- name: Release nightly
uses: softprops/action-gh-release@v1
with:
name: Canary - ${{ github.sha }}
tag_name: ${{ env.CANARY_TAG }}
name: Nightly - ${{ github.sha }}
tag_name: ${{ env.NIGHTLY_TAG }}
prerelease: true
append_body: true
token: ${{ secrets.GITHUB_TOKEN }}
files: |
release/debian/x11/*
release/debian/wayland/*
canary-release-windows:
nightly-release-windows:
needs: create_tag
if: ${{ needs.create_tag.outputs.created == 'true' }}
runs-on: windows-latest
Expand Down Expand Up @@ -179,11 +179,11 @@ jobs:
- run: cp ./target/release/rio.exe ./Rio-portable.exe

- name: Release canary
- name: Release Nightly
uses: softprops/action-gh-release@v1
with:
name: Canary - ${{ github.sha }}
tag_name: ${{ env.CANARY_TAG }}
name: Nightly - ${{ github.sha }}
tag_name: ${{ env.NIGHTLY_TAG }}
prerelease: true
append_body: true
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
51 changes: 41 additions & 10 deletions frontends/cross-winit/src/screen/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ use rio_backend::config::colors::{
AnsiColor, ColorArray, Colors, NamedColor,
};
use rio_backend::config::Config;
use rio_backend::sugarloaf::core::{Sugar, SugarDecoration, SugarStack, SugarStyle};
use rio_backend::sugarloaf::core::{
Sugar, SugarDecoration, SugarGraphic, SugarStack, SugarStyle,
};
use rio_backend::sugarloaf::Sugarloaf;
use std::collections::HashMap;
use std::rc::Rc;
Expand Down Expand Up @@ -136,6 +138,26 @@ impl State {
self.hyperlink_range.is_some()
}

#[inline]
fn create_graphic_sugar(&self, square: &Square) -> Sugar {
let foreground_color = self.compute_fg_color(square);
let background_color = self.compute_bg_color(square);

let media = &square.graphics().unwrap()[0].texture;
Sugar {
content: ' ',
foreground_color,
background_color,
style: None,
decoration: None,
media: Some(SugarGraphic {
id: media.id,
width: media.width,
height: media.height,
}),
}
}

#[inline]
fn create_sugar(&self, square: &Square) -> Sugar {
let flags = square.flags;
Expand Down Expand Up @@ -187,6 +209,7 @@ impl State {
background_color,
style,
decoration,
media: None,
}
}

Expand Down Expand Up @@ -248,6 +271,11 @@ impl State {
continue;
}

if square.flags.contains(Flags::GRAPHICS) {
stack.push(self.create_graphic_sugar(square));
continue;
}

if has_cursor && column == self.cursor.state.pos.col {
stack.push(self.create_cursor(square));
} else if self.hyperlink_range.is_some()
Expand Down Expand Up @@ -282,6 +310,7 @@ impl State {
background_color: self.named_colors.selection_background,
style: None,
decoration: None,
media: None,
};
stack.push(selected_sugar);
} else {
Expand Down Expand Up @@ -448,14 +477,8 @@ impl State {
}

if square.flags.contains(Flags::GRAPHICS) {
stack.push(Sugar {
content: ' ',
foreground_color: [0., 0., 0., 0.],
background_color: [0., 0., 0., 0.],
style: None,
decoration: None,
});
break;
stack.push(self.create_graphic_sugar(square));
continue;
}

if has_cursor && column == self.cursor.state.pos.col {
Expand All @@ -481,6 +504,7 @@ impl State {
background_color: self.compute_bg_color(square),
style: None,
decoration: None,
media: None,
};

let is_italic = square.flags.contains(Flags::ITALIC);
Expand Down Expand Up @@ -539,19 +563,26 @@ impl State {
}

#[inline]
#[allow(clippy::too_many_arguments)]
pub fn prepare_term(
&mut self,
rows: Vec<Row<Square>>,
cursor: CursorState,
sugarloaf: &mut Sugarloaf,
context_manager: &context::ContextManager<EventProxy>,
graphics: Option<UpdateQueues>,
graphics_opt: Option<UpdateQueues>,
display_offset: i32,
has_blinking_enabled: bool,
) {
self.cursor.state = cursor;
let mut is_cursor_visible = self.cursor.state.is_visible();

if let Some(graphics) = graphics_opt {
for graphic_data in graphics.pending {
sugarloaf.add_graphic(graphic_data);
}
}

self.font_size = sugarloaf.layout.font_size;

// Only blink cursor if does not contain selection
Expand Down
2 changes: 1 addition & 1 deletion rio-backend/src/ansi/graphics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use crate::config::colors::ColorRgb;
use crate::crosswords::grid::Dimensions;
use crate::sugarloaf::core::{ColorType, SugarGraphicData, SugarGraphicId};
use crate::sugarloaf::core::{SugarGraphicData, SugarGraphicId};
use parking_lot::Mutex;
use smallvec::SmallVec;
use std::mem;
Expand Down
3 changes: 3 additions & 0 deletions sugarloaf/benches/bench_sugar_pile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ fn bench_sugar_pile(c: &mut Criterion) {
foreground_color: [0.0, 0.0, 0.0, 1.0],
background_color: [0.0, 1.0, 1.0, 1.0],
style: None,
media: None,
decoration: None,
});

Expand All @@ -80,6 +81,7 @@ fn bench_sugar_pile(c: &mut Criterion) {
foreground_color: [0.0, 0.0, 0.0, 1.0],
background_color: [0.0, 1.0, 1.0, 1.0],
style: None,
media: None,
decoration: None,
});

Expand All @@ -88,6 +90,7 @@ fn bench_sugar_pile(c: &mut Criterion) {
foreground_color: [0.0, 0.0, 0.0, 1.0],
background_color: [0.0, 1.0, 1.0, 1.0],
style: None,
media: None,
decoration: None,
});
}
Expand Down
1 change: 1 addition & 0 deletions sugarloaf/benches/bench_sugar_pile_with_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ fn bench_sugar_pile_with_screen(c: &mut Criterion) {
foreground_color: [1.0, 1.0, 1.0, 1.0],
background_color: [0.0, 1.0, 1.0, 1.0],
style: None,
media: None,
decoration: None,
});
}
Expand Down
Loading

0 comments on commit 7c049b5

Please sign in to comment.