Skip to content

Commit

Permalink
fix readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Harzu committed Oct 5, 2024
1 parent 8c180cd commit 258cbe4
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 15 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ Terminal emulator widget powered by ICED framework and alacritty terminal backen

</div>

## Unstable widget API

The ICED fraemwork does not have the stable API and this widget is also under development, so I can not promise the stable API and to document it at least while the ICED won't release the 1.0.0 version.

## Features

The widget is currently under development and does not provide full terminal features make sure that widget is covered everything you want.
Expand All @@ -35,7 +39,7 @@ The widget is currently under development and does not provide full terminal fea
- Changing Font/Color scheme
- Hyperlinks processing (hover/open)

This widget tested on MacOS and Linux and is not tested on Windows.
This widget was tested on MacOS, Linux and Windows (but only under [WSL2](https://learn.microsoft.com/en-us/windows/wsl/about)).

## Installation

Expand All @@ -59,7 +63,7 @@ Interacting with the widget is happened via:
```rust
#[derive(Debug, Clone)]
pub enum Command {
InitBackend(Sender<alacritty_terminal::event::Event>),
InitBackend(Sender<AlacrittyEvent>),
ChangeTheme(Box<ColorPalette>),
ChangeFont(FontSettings),
AddBindings(Vec<(Binding<InputKind>, BindingAction)>),
Expand Down Expand Up @@ -165,7 +169,7 @@ impl App {
impl App {
// ... other methods
fn view(&self) -> Element<Event, Theme, iced::Renderer> {
container(iced_term::term_view(&self.term).map(Event::Terminal))
container(iced_term::TerminalView::show(&self.term).map(Event::Terminal))
.width(Length::Fill)
.height(Length::Fill)
.into()
Expand Down Expand Up @@ -208,7 +212,7 @@ fn main() -> iced::Result {
cargo run --release
```

**Step 9.** To be happy
**Step 9.** To be happy!

## Examples

Expand Down
2 changes: 1 addition & 1 deletion examples/custom_bindings/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl App {
}

fn view(&self) -> Element<Event, Theme, iced::Renderer> {
container(TerminalView::new(&self.term).map(Event::Terminal))
container(TerminalView::show(&self.term).map(Event::Terminal))
.width(Length::Fill)
.height(Length::Fill)
.into()
Expand Down
2 changes: 1 addition & 1 deletion examples/fonts/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl App {
.padding(8)
.on_press(Event::FontSizeDec),
],
row![TerminalView::new(&self.term).map(Event::Terminal)],
row![TerminalView::show(&self.term).map(Event::Terminal)],
];

container(content)
Expand Down
2 changes: 1 addition & 1 deletion examples/full_screen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl App {
}

fn view(&self) -> Element<Event, Theme, iced::Renderer> {
container(TerminalView::new(&self.term).map(Event::Terminal))
container(TerminalView::show(&self.term).map(Event::Terminal))
.width(Length::Fill)
.height(Length::Fill)
.into()
Expand Down
2 changes: 1 addition & 1 deletion examples/split_view/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ fn view_content(
tabs: &HashMap<u64, iced_term::Terminal>,
) -> Element<'_, Event> {
let tab = tabs.get(&pane_id).expect("tab with target id not found");
container(TerminalView::new(tab).map(Event::Terminal))
container(TerminalView::show(tab).map(Event::Terminal))
.width(Length::Fill)
.height(Length::Fill)
.padding(5)
Expand Down
2 changes: 1 addition & 1 deletion examples/themes/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl App {
}))
),
],
row![TerminalView::new(&self.term).map(Event::Terminal)]
row![TerminalView::show(&self.term).map(Event::Terminal)]
];

container(content)
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ mod theme;
mod view;

pub use alacritty_terminal::term::TermMode;
pub use alacritty_terminal::event::Event as AlacrittyEvent;
pub use subscription::Subscription;
pub use terminal::{Command, Event, Terminal};
pub use theme::{ColorPalette, Theme};
Expand Down
3 changes: 1 addition & 2 deletions src/settings.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use iced::Font;
use crate::ColorPalette;
use iced::Font;

#[cfg(target_os = "windows")]
const DEFAULT_SHELL: &str = "wsl.exe";

#[cfg(not(target_os = "windows"))]
const DEFAULT_SHELL: &str = "/bin/bash";


#[derive(Default, Clone)]
pub struct Settings {
pub font: FontSettings,
Expand Down
3 changes: 2 additions & 1 deletion src/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::bindings::{Binding, BindingAction, BindingsLayout, InputKind};
use crate::font::TermFont;
use crate::settings::{BackendSettings, FontSettings, Settings, ThemeSettings};
use crate::theme::{ColorPalette, Theme};
use crate::AlacrittyEvent;
use iced::widget::canvas::Cache;
use tokio::sync::mpsc::Sender;

Expand All @@ -14,7 +15,7 @@ pub enum Event {

#[derive(Debug, Clone)]
pub enum Command {
InitBackend(Sender<alacritty_terminal::event::Event>),
InitBackend(Sender<AlacrittyEvent>),
ChangeTheme(Box<ColorPalette>),
ChangeFont(FontSettings),
AddBindings(Vec<(Binding<InputKind>, BindingAction)>),
Expand Down
3 changes: 1 addition & 2 deletions src/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ fn build_ansi256_colors() -> HashMap<u8, Color> {
let index: u8 = 232;
for i in 0..24 {
let value = i * 10 + 8;
ansi256_colors
.insert(index + i, Color::from_rgb8(value, value, value));
ansi256_colors.insert(index + i, Color::from_rgb8(value, value, value));
}

ansi256_colors
Expand Down
2 changes: 1 addition & 1 deletion src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct TerminalView<'a> {
}

impl<'a> TerminalView<'a> {
pub fn new(term: &'a Terminal) -> Element<'_, Event> {
pub fn show(term: &'a Terminal) -> Element<'_, Event> {
container(Self { term })
.width(Length::Fill)
.height(Length::Fill)
Expand Down

0 comments on commit 258cbe4

Please sign in to comment.