Skip to content

Commit

Permalink
update docs regarding bookmark
Browse files Browse the repository at this point in the history
  • Loading branch information
raphamorim committed Sep 14, 2024
1 parent ac915b8 commit 767d756
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 56 deletions.
18 changes: 8 additions & 10 deletions docs/docs/config/navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ language: 'en'

```toml
[navigation]
mode = "CollapsedTab"
mode = "Bookmark"
clickable = false
hide-if-single = true
use-current-path = false
Expand All @@ -19,23 +19,23 @@ color-automation = []

Rio has multiple styles of showing navigation/tabs.

### CollapsedTab
### Bookmark

Note: The example below is using the [Dracula](https://github.com/dracula/rio-terminal) color scheme instead of Rio default colors.

`Bookmark` is the default navigation mode.

<img src="https://miro.medium.com/v2/resize:fit:1400/format:webp/1*gMLWcZkniSHUT6Cb7L06Gg.png" width="60%" />

Usage:

```toml
[navigation]
mode = "CollapsedTab"
mode = "Bookmark"
```

### NativeTab (MacOS only)

`NativeTab` is the default navigation mode for MacOS.

<img alt="Demo NativeTab" src="/rio/assets/posts/0.0.17/demo-native-tabs.png" width="60%"/>

Usage:
Expand All @@ -47,8 +47,6 @@ mode = "NativeTab"

### BottomTab

`BottomTab` is the default navigation mode for Linux, BSD and Windows.

Note: `BottomTab` does not support click mode yet.

<img alt="Demo BottomTab" src="/rio/assets/features/demo-bottom-tab.png" width="58%"/>
Expand Down Expand Up @@ -128,7 +126,7 @@ The example below sets `#FFFF00` as color background whenever `nvim` is running.
<p>
<img alt="example navigation with program color automation using BottomTab" src="/rio/assets/features/demo-colorized-navigation.png" width="48%"/>

<img alt="example navigation with program color automation using CollapsedTab" src="/rio/assets/features/demo-colorized-navigation-2.png" width="48%"/>
<img alt="example navigation with program color automation using Bookmark" src="/rio/assets/features/demo-colorized-navigation-2.png" width="48%"/>
</p>

The configuration would be like:
Expand Down Expand Up @@ -158,7 +156,7 @@ color-automation = [
<p>
<img alt="example navigation with path color automation using TopTab" src="/rio/assets/features/demo-colorized-navigation-path-1.png" width="48%"/>

<img alt="example navigation with path color automation using CollapsedTab" src="/rio/assets/features/demo-colorized-navigation-path-2.png" width="48%"/>
<img alt="example navigation with path color automation using Bookmark" src="/rio/assets/features/demo-colorized-navigation-path-2.png" width="48%"/>
</p>

#### Program and path
Expand All @@ -181,5 +179,5 @@ color-automation = [
<p>
<img alt="example navigation with program and path color automation using TopTab" src="/rio/assets/features/demo-colorized-navigation-program-and-path-1.png" width="48%"/>

<img alt="example navigation with program and path color automation using CollapsedTab" src="/rio/assets/features/demo-colorized-navigation-program-and-path-2.png" width="48%"/>
<img alt="example navigation with program and path color automation using Bookmark" src="/rio/assets/features/demo-colorized-navigation-program-and-path-2.png" width="48%"/>
</p>
2 changes: 1 addition & 1 deletion docs/docs/features/navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Rio support different types of navigation modes:
</p>

<p>
<img alt="Demo CollapsedTab" src="https://miro.medium.com/v2/resize:fit:1400/format:webp/1*gMLWcZkniSHUT6Cb7L06Gg.png" width="48%" />
<img alt="Demo Bookmark" src="https://miro.medium.com/v2/resize:fit:1400/format:webp/1*gMLWcZkniSHUT6Cb7L06Gg.png" width="48%" />
<img alt="Demo BottomTab" src="/rio/assets/features/demo-bottom-tab.png" width="48%"/>
</p>

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Rio support different types of navigation modes:
</p>

<p>
<img alt="Demo CollapsedTab" src="https://miro.medium.com/v2/resize:fit:1400/format:webp/1*gMLWcZkniSHUT6Cb7L06Gg.png" width="48%" />
<img alt="Demo Bookmark" src="https://miro.medium.com/v2/resize:fit:1400/format:webp/1*gMLWcZkniSHUT6Cb7L06Gg.png" width="48%" />
<img alt="Demo BottomTab" src="/rio/assets/features/demo-bottom-tab.png" width="48%"/>
</p>

Expand Down
3 changes: 1 addition & 2 deletions docs/docs/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ language: 'en'

<!-- - Fix: MacOS Delete key doesn't work in kitty mode [#513](https://github.com/raphamorim/rio/issues/513). -->
<!-- - Fix: Kitty keyboard protocol doesn't work with tmux [#599](https://github.com/raphamorim/rio/issues/599). -->
- **breaking**: `CollapsedTab` has been renamed to `Bookmark`.
- MacOS does not clear with background operation anymore, instead it relies on window background.
- Background color has changed to `#0F0D0E`.
- Default navigation on MacOS is now `NativeTab` with `window.decorations = "transparent"`.
- Default navigation on Linux/BSD/Windows is now BottomTab.
- Fix font emoji width.
- Fix MacOS tabbing when spawned from a new window.

Expand Down
6 changes: 3 additions & 3 deletions frontends/rioterm/src/renderer/navigation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ impl ScreenNavigation {
match self.navigation.mode {
#[cfg(target_os = "macos")]
NavigationMode::NativeTab => {}
NavigationMode::CollapsedTab => {
self.collapsed_tab(titles, colors, len, self.navigation.hide_if_single)
NavigationMode::Bookmark => {
self.bookmark(titles, colors, len, self.navigation.hide_if_single)
}
NavigationMode::TopTab => {
let position_y = 0.0;
Expand Down Expand Up @@ -132,7 +132,7 @@ impl ScreenNavigation {
}

#[inline]
pub fn collapsed_tab(
pub fn bookmark(
&mut self,
titles: &HashMap<usize, [String; 3]>,
colors: &Colors,
Expand Down
40 changes: 13 additions & 27 deletions rio-backend/src/config/navigation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::config::colors::{deserialize_to_arr, ColorArray};
use crate::config::default_bool_true;
use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Copy)]
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Clone, Copy)]
pub enum NavigationMode {
#[serde(alias = "plain")]
Plain,
Expand All @@ -13,28 +13,14 @@ pub enum NavigationMode {
NativeTab,
#[serde(alias = "bottomtab")]
BottomTab,
#[serde(alias = "collapsedtab")]
CollapsedTab,
}

#[allow(clippy::derivable_impls)]
impl Default for NavigationMode {
fn default() -> Self {
#[cfg(target_os = "macos")]
{
NavigationMode::NativeTab
}

#[cfg(not(target_os = "macos"))]
{
NavigationMode::BottomTab
}
}
#[serde(alias = "bookmark")]
#[default]
Bookmark,
}

impl NavigationMode {
const PLAIN_STR: &'static str = "Plain";
const COLLAPSED_TAB_STR: &'static str = "CollapsedTab";
const COLLAPSED_TAB_STR: &'static str = "Bookmark";
const TOP_TAB_STR: &'static str = "TopTab";
const BOTTOM_TAB_STR: &'static str = "BottomTab";
#[cfg(target_os = "macos")]
Expand All @@ -43,7 +29,7 @@ impl NavigationMode {
pub fn as_str(&self) -> &'static str {
match self {
Self::Plain => Self::PLAIN_STR,
Self::CollapsedTab => Self::COLLAPSED_TAB_STR,
Self::Bookmark => Self::COLLAPSED_TAB_STR,
Self::TopTab => Self::TOP_TAB_STR,
Self::BottomTab => Self::BOTTOM_TAB_STR,
#[cfg(target_os = "macos")]
Expand All @@ -56,7 +42,7 @@ impl NavigationMode {
pub fn modes_as_vec_string() -> Vec<String> {
[
NavigationMode::Plain,
NavigationMode::CollapsedTab,
NavigationMode::Bookmark,
NavigationMode::TopTab,
NavigationMode::BottomTab,
#[cfg(target_os = "macos")]
Expand All @@ -81,7 +67,7 @@ impl std::str::FromStr for NavigationMode {

fn from_str(s: &str) -> Result<NavigationMode, ParseNavigationModeError> {
match s {
Self::COLLAPSED_TAB_STR => Ok(NavigationMode::CollapsedTab),
Self::COLLAPSED_TAB_STR => Ok(NavigationMode::Bookmark),
Self::TOP_TAB_STR => Ok(NavigationMode::TopTab),
Self::BOTTOM_TAB_STR => Ok(NavigationMode::BottomTab),
#[cfg(target_os = "macos")]
Expand Down Expand Up @@ -141,7 +127,7 @@ impl Default for Navigation {
impl Navigation {
#[inline]
pub fn is_collapsed_mode(&self) -> bool {
self.mode == NavigationMode::CollapsedTab
self.mode == NavigationMode::Bookmark
}

#[inline]
Expand Down Expand Up @@ -189,11 +175,11 @@ mod tests {
fn test_collapsed_tab() {
let content = r#"
[navigation]
mode = 'CollapsedTab'
mode = 'Bookmark'
"#;

let decoded = toml::from_str::<Root>(content).unwrap();
assert_eq!(decoded.navigation.mode, NavigationMode::CollapsedTab);
assert_eq!(decoded.navigation.mode, NavigationMode::Bookmark);
assert!(!decoded.navigation.clickable);
assert!(decoded.navigation.color_automation.is_empty());
}
Expand Down Expand Up @@ -230,14 +216,14 @@ mod tests {
fn test_color_automation() {
let content = r#"
[navigation]
mode = 'CollapsedTab'
mode = 'Bookmark'
color-automation = [
{ program = 'vim', color = '#333333' }
]
"#;

let decoded = toml::from_str::<Root>(content).unwrap();
assert_eq!(decoded.navigation.mode, NavigationMode::CollapsedTab);
assert_eq!(decoded.navigation.mode, NavigationMode::Bookmark);
assert!(!decoded.navigation.clickable);
assert!(!decoded.navigation.use_current_path);
assert!(!decoded.navigation.color_automation.is_empty());
Expand Down
14 changes: 2 additions & 12 deletions rio-backend/src/config/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ pub enum WindowMode {
Windowed,
}

#[derive(Clone, Serialize, Deserialize, Copy, Debug, PartialEq)]
#[derive(Clone, Default, Serialize, Deserialize, Copy, Debug, PartialEq)]
pub enum Decorations {
#[serde(alias = "enabled")]
#[default]
Enabled,
#[serde(alias = "disabled")]
Disabled,
Expand All @@ -26,17 +27,6 @@ pub enum Decorations {
Buttonless,
}

#[allow(clippy::derivable_impls)]
impl Default for Decorations {
fn default() -> Decorations {
if cfg!(target_os = "macos") {
Decorations::Transparent
} else {
Decorations::Enabled
}
}
}

#[derive(PartialEq, Serialize, Deserialize, Clone, Debug)]
pub struct Window {
#[serde(default = "default_window_width")]
Expand Down

0 comments on commit 767d756

Please sign in to comment.