mirror of https://github.com/lapce/lapce.git
terminal update content update
This commit is contained in:
parent
25579ace17
commit
0ff6b4534f
|
@ -1932,6 +1932,7 @@ version = "0.0.1"
|
|||
dependencies = [
|
||||
"alacritty_terminal",
|
||||
"anyhow",
|
||||
"base64 0.13.0",
|
||||
"bit-vec 0.5.1",
|
||||
"cc",
|
||||
"config",
|
||||
|
@ -1992,6 +1993,7 @@ version = "0.0.1"
|
|||
dependencies = [
|
||||
"alacritty_terminal",
|
||||
"anyhow",
|
||||
"base64 0.13.0",
|
||||
"crossbeam-channel 0.5.1",
|
||||
"git2",
|
||||
"home",
|
||||
|
|
|
@ -5,6 +5,7 @@ authors = ["Dongdong Zhou <dzhou121@gmail.com>"]
|
|||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
base64 = "0.13.0"
|
||||
alacritty_terminal = "0.15.0"
|
||||
config = "0.11"
|
||||
indexmap = "1.7.0"
|
||||
|
|
|
@ -384,7 +384,7 @@ pub enum LapceUICommand {
|
|||
UpdateLineChanges(BufferId),
|
||||
PublishDiagnostics(PublishDiagnosticsParams),
|
||||
UpdateDiffFiles(Vec<PathBuf>),
|
||||
TerminalUpdateContent(TermId, TerminalContent),
|
||||
TerminalUpdateContent(TermId, Arc<TerminalContent>),
|
||||
ReloadBuffer(BufferId, u64, String),
|
||||
EnsureVisible((Rect, (f64, f64), Option<EnsureVisiblePosition>)),
|
||||
EnsureRectVisible(Rect),
|
||||
|
|
|
@ -411,7 +411,7 @@ pub enum Notification {
|
|||
},
|
||||
UpdateTerminal {
|
||||
term_id: TermId,
|
||||
content: Vec<u8>,
|
||||
content: String,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ pub struct LapceTerminalData {
|
|||
pub widget_id: WidgetId,
|
||||
pub split_id: WidgetId,
|
||||
pub panel_widget_id: Option<WidgetId>,
|
||||
pub content: TerminalContent,
|
||||
pub content: Arc<TerminalContent>,
|
||||
}
|
||||
|
||||
impl LapceTerminalData {
|
||||
|
@ -208,7 +208,7 @@ pub fn new(
|
|||
widget_id,
|
||||
split_id,
|
||||
panel_widget_id,
|
||||
content: TerminalContent::new(),
|
||||
content: Arc::new(TerminalContent::new()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -282,9 +282,9 @@ pub fn run(&mut self, receiver: Receiver<TerminalEvent>) -> Result<()> {
|
|||
}
|
||||
alacritty_terminal::event::Event::CursorBlinkingChange(_) => {}
|
||||
alacritty_terminal::event::Event::Wakeup => {
|
||||
let content = TerminalContent {
|
||||
let content = Arc::new(TerminalContent {
|
||||
grid: self.term.grid().clone(),
|
||||
};
|
||||
});
|
||||
self.event_sink.submit_command(
|
||||
LAPCE_UI_COMMAND,
|
||||
LapceUICommand::TerminalUpdateContent(
|
||||
|
@ -298,7 +298,7 @@ pub fn run(&mut self, receiver: Receiver<TerminalEvent>) -> Result<()> {
|
|||
alacritty_terminal::event::Event::Exit => {}
|
||||
},
|
||||
TerminalEvent::UpdateContent(content) => {
|
||||
self.update_content(&content);
|
||||
self.update_content(content);
|
||||
self.sender.send(TerminalEvent::Event(
|
||||
alacritty_terminal::event::Event::Wakeup,
|
||||
));
|
||||
|
@ -307,9 +307,11 @@ pub fn run(&mut self, receiver: Receiver<TerminalEvent>) -> Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn update_content(&mut self, content: &[u8]) {
|
||||
pub fn update_content(&mut self, content: String) {
|
||||
if let Ok(content) = base64::decode(content) {
|
||||
for byte in content {
|
||||
self.parser.advance(&mut self.term, *byte);
|
||||
self.parser.advance(&mut self.term, byte);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -694,7 +696,7 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
|||
pub enum TerminalEvent {
|
||||
Resize(usize, usize),
|
||||
Event(alacritty_terminal::event::Event),
|
||||
UpdateContent(Vec<u8>),
|
||||
UpdateContent(String),
|
||||
}
|
||||
|
||||
pub enum TerminalHostEvent {
|
||||
|
@ -705,7 +707,7 @@ pub enum TerminalHostEvent {
|
|||
Exit,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Debug)]
|
||||
pub struct TerminalContent {
|
||||
grid: Grid<Cell>,
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ authors = ["Dongdong Zhou <dzhou121@gmail.com>"]
|
|||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
base64 = "0.13.0"
|
||||
alacritty_terminal = "0.15.0"
|
||||
mio = "0.6.20"
|
||||
notify = "4.0.16"
|
||||
|
|
|
@ -121,7 +121,7 @@ pub fn run(&mut self, dispatcher: Dispatcher) {
|
|||
"update_terminal",
|
||||
json!({
|
||||
"term_id": self.term_id,
|
||||
"content": buf[..n],
|
||||
"content": base64::encode(&buf[..n]),
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue