Skip to content

Commit 1fd5684

Browse files
authored
fix: running edit in egui_term (#37)
* fix * fix running edit in egui_term
1 parent e74d155 commit 1fd5684

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

crates/egui-term/src/alacritty/mod.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,10 @@ impl Terminal {
230230
let event_proxy = EventProxy(event_sender);
231231
let term = Term::new(config, &term_size, event_proxy.clone());
232232
let term = Arc::new(FairMutex::new(term));
233+
233234
let pty_event_loop = EventLoop::new(term.clone(), event_proxy, pty, false, false)?;
234235
let notifier = Notifier(pty_event_loop.channel());
236+
let pty_notifier = Notifier(pty_event_loop.channel());
235237

236238
let url_regex = r#"(ipfs:|ipns:|magnet:|mailto:|gemini://|gopher://|https://|http://|news:|file://|git://|ssh:|ftp://)[^\u{0000}-\u{001F}\u{007F}-\u{009F}<>"\s{-}\^⟨⟩`]+"#;
237239
let url_regex =
@@ -246,8 +248,10 @@ impl Terminal {
246248
panic!("pty_event_subscription_{id}: sending PtyEvent is failed, error: {err}")
247249
});
248250
app_context.request_repaint();
249-
if let Event::Exit = event {
250-
break;
251+
match event {
252+
Event::Exit => break,
253+
Event::PtyWrite(s) => pty_notifier.notify(s.into_bytes()),
254+
_ => {}
251255
}
252256
})?;
253257

@@ -353,6 +357,7 @@ impl<'a> TerminalContext<'a> {
353357
pub fn write_data<I: Into<Cow<'static, [u8]>>>(&mut self, data: I) {
354358
self.write(data);
355359
self.terminal.scroll_display(Scroll::Bottom);
360+
self.terminal.selection = None;
356361
}
357362

358363
fn process_link(&mut self, link_action: LinkAction, point: Point) {

crates/egui-term/src/view.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,15 @@ impl<'a> TerminalView<'a> {
256256
modifiers,
257257
pos,
258258
} => {
259-
let new_pos = if is_in_terminal(pos, layout.rect) {
260-
pos
261-
} else {
259+
let out_of = !is_in_terminal(pos, layout.rect);
260+
if out_of && pressed {
261+
continue;
262+
}
263+
264+
let new_pos = if out_of {
262265
pos.clamp(layout.rect.min, layout.rect.max)
266+
} else {
267+
pos
263268
};
264269

265270
if let Some(action) =

0 commit comments

Comments
 (0)