Skip to content

Commit

Permalink
Merge branch 'raphamorim:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
yonas authored Sep 17, 2024
2 parents 6fbf023 + adf1579 commit 471e48f
Show file tree
Hide file tree
Showing 12 changed files with 371 additions and 343 deletions.
5 changes: 5 additions & 0 deletions docs/docs/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ 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`.
- Memory usage reduced by 75% (avg ~201mb to 48mb on first screen render).
- Implemented font data deallocator.
- Reduced font atlas buffer size to `1024`.
- Added lifetimes to application level (allowing to deallocate window structs once is removed).
- Migrated font context from `RwLock` to `Arc<FairMutex>`.
- MacOS does not clear with background operation anymore, instead it relies on window background.
- Background color has changed to `#0F0D0E`.
- Fix font emoji width.
Expand Down
12 changes: 6 additions & 6 deletions frontends/rioterm/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ use rio_window::window::{CursorIcon, Fullscreen};
use std::error::Error;
use std::time::{Duration, Instant};

pub struct Application {
pub struct Application<'a> {
config: rio_backend::config::Config,
event_proxy: EventProxy,
router: Router,
router: Router<'a>,
scheduler: Scheduler,
}

impl Application {
pub fn new(
impl Application<'_> {
pub fn new<'app>(
config: rio_backend::config::Config,
config_error: Option<rio_backend::config::ConfigError>,
event_loop: &EventLoop<EventPayload>,
) -> Application {
) -> Application<'app> {
// SAFETY: Since this takes a pointer to the winit event loop, it MUST be dropped first,
// which is done in `loop_exiting`.
let clipboard =
Expand Down Expand Up @@ -94,7 +94,7 @@ impl Application {
}
}

impl ApplicationHandler<EventPayload> for Application {
impl ApplicationHandler<EventPayload> for Application<'_> {
fn resumed(&mut self, _active_event_loop: &ActiveEventLoop) {
#[cfg(not(any(target_os = "macos", windows)))]
{
Expand Down
33 changes: 14 additions & 19 deletions frontends/rioterm/src/renderer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ impl Renderer {
) {
let columns: usize = row.len();
let mut content = String::default();
let mut last_char_was_empty = false;
let mut last_char_was_space = false;
let mut last_style = FragmentStyle::default();

for column in 0..columns {
Expand Down Expand Up @@ -405,14 +405,23 @@ impl Renderer {
);
};

// TODO: Write tests for it
if square_content != ' ' && last_char_was_empty {
if !content.is_empty() {
if square_content == ' ' {
if !last_char_was_space {
if !content.is_empty() {
content_builder.add_text(&content, last_style);
content.clear();
}

last_char_was_space = true;
last_style = style;
}
} else {
if last_char_was_space && !content.is_empty() {
content_builder.add_text(&content, last_style);
content.clear();
}

last_char_was_empty = false;
last_char_was_space = false;
}

if last_style != style {
Expand All @@ -424,26 +433,12 @@ impl Renderer {
last_style = style;
}

if square_content == ' ' && !last_char_was_empty {
if !content.is_empty() {
content_builder.add_text(&content, last_style);
content.clear();
}

content.push(square_content);
last_char_was_empty = true;
continue;
}

content.push(square_content);

// Render last column and break row
if column == (columns - 1) {
if !content.is_empty() {
// let start = std::time::Instant::now();
content_builder.add_text(&content, last_style);
// let duration = start.elapsed();
// println!("Total add_text: {:?}", duration);
}

break;
Expand Down
48 changes: 24 additions & 24 deletions frontends/rioterm/src/router/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ use std::rc::Rc;
// #[cfg(not(any(target_os = "macos", target_os = "windows")))]
const RIO_TITLE: &str = "▲";

pub struct Route {
pub struct Route<'a> {
pub assistant: assistant::Assistant,
pub path: RoutePath,
pub window: RouteWindow,
pub window: RouteWindow<'a>,
}

impl Route {
impl Route<'_> {
/// Create a performer.
#[inline]
pub fn new(
Expand All @@ -49,7 +49,7 @@ impl Route {
}
}

impl Route {
impl Route<'_> {
#[inline]
pub fn request_redraw(&mut self) {
self.window.winit_window.request_redraw();
Expand Down Expand Up @@ -141,19 +141,19 @@ impl Route {
}
}

pub struct Router {
pub routes: HashMap<WindowId, Route>,
pub struct Router<'a> {
pub routes: HashMap<WindowId, Route<'a>>,
propagated_report: Option<RioError>,
pub font_library: Box<rio_backend::sugarloaf::font::FontLibrary>,
pub config_route: Option<WindowId>,
pub clipboard: Rc<RefCell<Clipboard>>,
}

impl Router {
pub fn new(
impl Router<'_> {
pub fn new<'b>(
fonts: rio_backend::sugarloaf::font::SugarloafFonts,
clipboard: Clipboard,
) -> Router {
) -> Router<'b> {
let (font_library, fonts_not_found) =
rio_backend::sugarloaf::font::FontLibrary::new(fonts);

Expand Down Expand Up @@ -238,11 +238,11 @@ impl Router {
}

#[inline]
pub fn create_window(
&mut self,
event_loop: &ActiveEventLoop,
pub fn create_window<'a>(
&'a mut self,
event_loop: &'a ActiveEventLoop,
event_proxy: EventProxy,
config: &rio_backend::config::Config,
config: &'a rio_backend::config::Config,
open_url: Option<String>,
) {
let tab_id = if config.navigation.is_native() {
Expand Down Expand Up @@ -279,11 +279,11 @@ impl Router {

#[cfg(target_os = "macos")]
#[inline]
pub fn create_native_tab(
&mut self,
event_loop: &ActiveEventLoop,
pub fn create_native_tab<'a>(
&'a mut self,
event_loop: &'a ActiveEventLoop,
event_proxy: EventProxy,
config: &rio_backend::config::Config,
config: &'a rio_backend::config::Config,
tab_id: Option<&str>,
open_url: Option<String>,
) {
Expand All @@ -308,33 +308,33 @@ impl Router {
}
}

pub struct RouteWindow {
pub struct RouteWindow<'a> {
pub is_focused: bool,
pub is_occluded: bool,
pub has_frame: bool,
pub has_updates: bool,
pub winit_window: Window,
pub screen: Screen<'static>,
pub screen: Screen<'a>,
#[cfg(target_os = "macos")]
pub is_macos_deadzone: bool,
}

impl RouteWindow {
impl<'a> RouteWindow<'a> {
pub fn configure_window(&mut self, config: &rio_backend::config::Config) {
configure_window(&self.winit_window, config);
}

#[allow(clippy::too_many_arguments)]
pub fn from_target(
event_loop: &ActiveEventLoop,
pub fn from_target<'b>(
event_loop: &'b ActiveEventLoop,
event_proxy: EventProxy,
config: &RioConfig,
config: &'b RioConfig,
font_library: &rio_backend::sugarloaf::font::FontLibrary,
window_name: &str,
tab_id: Option<&str>,
open_url: Option<String>,
clipboard: Rc<RefCell<Clipboard>>,
) -> RouteWindow {
) -> RouteWindow<'a> {
#[allow(unused_mut)]
let mut window_builder = create_window_builder(window_name, config, tab_id);

Expand Down
48 changes: 24 additions & 24 deletions rio-backend/src/crosswords/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,30 +76,30 @@ bitflags! {
#[derive(Debug, Copy, Clone)]
pub struct Mode: u32 {
const NONE = 0;
const SHOW_CURSOR = 0b0000_0000_0000_0000_0000_0001;
const APP_CURSOR = 0b0000_0000_0000_0000_0000_0010;
const APP_KEYPAD = 0b0000_0000_0000_0000_0000_0100;
const MOUSE_REPORT_CLICK = 0b0000_0000_0000_0000_0000_1000;
const BRACKETED_PASTE = 0b0000_0000_0000_0000_0001_0000;
const SGR_MOUSE = 0b0000_0000_0000_0000_0010_0000;
const MOUSE_MOTION = 0b0000_0000_0000_0000_0100_0000;
const LINE_WRAP = 0b0000_0000_0000_0000_1000_0000;
const LINE_FEED_NEW_LINE = 0b0000_0000_0000_0001_0000_0000;
const ORIGIN = 0b0000_0000_0000_0010_0000_0000;
const INSERT = 0b0000_0000_0000_0100_0000_0000;
const FOCUS_IN_OUT = 0b0000_0000_0000_1000_0000_0000;
const ALT_SCREEN = 0b0000_0000_0001_0000_0000_0000;
const MOUSE_DRAG = 0b0000_0000_0010_0000_0000_0000;
const MOUSE_MODE = 0b0000_0000_0010_0000_0100_1000;
const UTF8_MOUSE = 0b0000_0000_0100_0000_0000_0000;
const ALTERNATE_SCROLL = 0b0000_0000_1000_0000_0000_0000;
const VI = 0b0000_0001_0000_0000_0000_0000;
const URGENCY_HINTS = 0b0000_0010_0000_0000_0000_0000;
const DISAMBIGUATE_ESC_CODES = 0b0000_0100_0000_0000_0000_0000;
const REPORT_EVENT_TYPES = 0b0000_1000_0000_0000_0000_0000;
const REPORT_ALTERNATE_KEYS = 0b0001_0000_0000_0000_0000_0000;
const REPORT_ALL_KEYS_AS_ESC = 0b0010_0000_0000_0000_0000_0000;
const REPORT_ASSOCIATED_TEXT = 0b0100_0000_0000_0000_0000_0000;
const SHOW_CURSOR = 1;
const APP_CURSOR = 1 << 1;
const APP_KEYPAD = 1 << 2;
const MOUSE_REPORT_CLICK = 1 << 3;
const BRACKETED_PASTE = 1 << 4;
const SGR_MOUSE = 1 << 5;
const MOUSE_MOTION = 1 << 6;
const LINE_WRAP = 1 << 7;
const LINE_FEED_NEW_LINE = 1 << 8;
const ORIGIN = 1 << 9;
const INSERT = 1 << 10;
const FOCUS_IN_OUT = 1 << 11;
const ALT_SCREEN = 1 << 12;
const MOUSE_DRAG = 1 << 13;
const UTF8_MOUSE = 1 << 14;
const ALTERNATE_SCROLL = 1 << 15;
const VI = 1 << 16;
const URGENCY_HINTS = 1 << 17;
const DISAMBIGUATE_ESC_CODES = 1 << 18;
const REPORT_EVENT_TYPES = 1 << 19;
const REPORT_ALTERNATE_KEYS = 1 << 20;
const REPORT_ALL_KEYS_AS_ESC = 1 << 21;
const REPORT_ASSOCIATED_TEXT = 1 << 22;
const MOUSE_MODE = Self::MOUSE_REPORT_CLICK.bits() | Self::MOUSE_MOTION.bits() | Self::MOUSE_DRAG.bits();
const KITTY_KEYBOARD_PROTOCOL = Self::DISAMBIGUATE_ESC_CODES.bits()
| Self::REPORT_EVENT_TYPES.bits()
| Self::REPORT_ALTERNATE_KEYS.bits()
Expand Down
2 changes: 1 addition & 1 deletion sugarloaf/src/components/rich_text/image_cache/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn buffer_size(width: u32, height: u32) -> Option<usize> {
.checked_add(4)
}

pub const SIZE: u16 = 3072;
pub const SIZE: u16 = 2048;

impl ImageCache {
/// Creates a new image cache.
Expand Down
Loading

0 comments on commit 471e48f

Please sign in to comment.