Skip to content

Commit 990aede

Browse files
committed
Rio 0.0.4
1 parent 7a6735c commit 990aede

File tree

5 files changed

+36
-11
lines changed

5 files changed

+36
-11
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## 0.0.4
44

5+
- Fix CPU large usage when scrolling.
6+
- Task scheduler.
57
- Copy feature.
68
- Selection feature (selection doesn't work when scrolling yet).
79
- Change default cursor icon for Text (`winit::window::CursorIcon`).

rio/src/event/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl From<RioEvent> for RioEventType {
124124
pub struct EventP {
125125
/// Event payload.
126126
pub payload: RioEventType,
127-
pub tab_id: u8
127+
pub tab_id: u8,
128128
}
129129

130130
impl EventP {

rio/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
mod scheduler;
21
mod ansi;
32
mod clipboard;
43
mod crosswords;
@@ -8,6 +7,7 @@ mod layout;
87
mod logger;
98
mod performer;
109
mod platform;
10+
mod scheduler;
1111
mod screen;
1212
mod selection;
1313
mod sequencer;

rio/src/scheduler.rs

+22-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl TimerId {
2020
/// Available timer topics.
2121
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
2222
pub enum Topic {
23-
#[allow(dead_code)]
23+
#[allow(dead_code)]
2424
SelectionScrolling,
2525
Frame,
2626
}
@@ -42,7 +42,10 @@ pub struct Scheduler {
4242

4343
impl Scheduler {
4444
pub fn new(event_proxy: EventLoopProxy<EventP>) -> Self {
45-
Self { timers: VecDeque::new(), event_proxy }
45+
Self {
46+
timers: VecDeque::new(),
47+
event_proxy,
48+
}
4649
}
4750

4851
/// Process all pending timers.
@@ -67,7 +70,13 @@ impl Scheduler {
6770
}
6871

6972
/// Schedule a new event.
70-
pub fn schedule(&mut self, event: EventP, interval: Duration, repeat: bool, timer_id: TimerId) {
73+
pub fn schedule(
74+
&mut self,
75+
event: EventP,
76+
interval: Duration,
77+
repeat: bool,
78+
timer_id: TimerId,
79+
) {
7180
let deadline = Instant::now() + interval;
7281

7382
// Get insert position in the schedule.
@@ -80,7 +89,15 @@ impl Scheduler {
8089
// Set the automatic event repeat rate.
8190
let interval = if repeat { Some(interval) } else { None };
8291

83-
self.timers.insert(index, Timer { interval, deadline, event, id: timer_id });
92+
self.timers.insert(
93+
index,
94+
Timer {
95+
interval,
96+
deadline,
97+
event,
98+
id: timer_id,
99+
},
100+
);
84101
}
85102

86103
/// Cancel a scheduled event.
@@ -104,4 +121,4 @@ impl Scheduler {
104121
pub fn unschedule_tab(&mut self, tab_id: u8) {
105122
self.timers.retain(|timer| timer.id.tab_id != tab_id);
106123
}
107-
}
124+
}

rio/src/sequencer.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::clipboard::ClipboardType;
2-
use crate::scheduler::{TimerId, Topic, Scheduler};
32
use crate::event::{ClickState, EventP, EventProxy, RioEvent, RioEventType};
43
use crate::ime::Preedit;
4+
use crate::scheduler::{Scheduler, TimerId, Topic};
55
use crate::screen::{window::create_window_builder, Screen};
66
use std::error::Error;
77
use std::rc::Rc;
@@ -86,9 +86,15 @@ impl Sequencer {
8686
}
8787
RioEvent::PrepareRender(millis) => {
8888
let timer_id = TimerId::new(Topic::Frame, 0);
89-
let event = EventP::new(RioEventType::Rio(RioEvent::Render));
90-
91-
scheduler.schedule(event, Duration::from_millis(millis), false, timer_id);
89+
let event =
90+
EventP::new(RioEventType::Rio(RioEvent::Render));
91+
92+
scheduler.schedule(
93+
event,
94+
Duration::from_millis(millis),
95+
false,
96+
timer_id,
97+
);
9298
}
9399
RioEvent::Title(_title) => {
94100
// if !self.ctx.preserve_title && self.ctx.config.window.dynamic_title {

0 commit comments

Comments
 (0)