Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change redraw #98

Merged
merged 2 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion crates/erars-stdio/src/stdio_frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ impl StdioFrontend {
let ret = vconsole.make_serializable(self.from);

serde_json::to_writer(&mut out, &ret)?;
writeln!(out)?;

self.from += ret.lines.len();
vconsole.need_rebuild = false;
Expand Down Expand Up @@ -103,7 +104,6 @@ impl SystemFunctions for StdioFrontend {
if self.json {
let out = io::stdout();
let mut out = out.lock();
writeln!(out)?;
serde_json::to_writer(&mut out, &req)?;
writeln!(out)?;
}
Expand Down Expand Up @@ -139,6 +139,10 @@ impl SystemFunctions for StdioFrontend {
}

async fn redraw(&mut self, vconsole: &mut VirtualConsole) -> anyhow::Result<()> {
if !vconsole.need_rebuild && self.from == vconsole.line_count() && vconsole.line_is_empty() {
// skip redraw
return Ok(());
}
self.draw(vconsole, &mut io::stdout().lock())
}
async fn load_local_list(&mut self) -> anyhow::Result<SaveList> {
Expand Down
2 changes: 0 additions & 2 deletions crates/erars-vm/src/terminal_vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ impl TerminalVm {
let insts = body.body();
let func_name = func_identifier.get_key(&ctx.var);

ctx.system.redraw(tx).await?;

while let Some(inst) = insts.get(cursor).copied() {
use InstructionWorkflow::*;

Expand Down
11 changes: 10 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,24 @@
);
in rec
{
devShell = pkgs.mkShell {
devShell = pkgs.mkShell rec {
name = "erars-shell";
nativeBuildInputs = with pkgs; [
pkg-config
cmake
rustfmt
rustc
cargo
just
];
buildInputs = with pkgs; [
fontconfig
xorg.libX11
xorg.libXcursor
xorg.libXrandr
xorg.libXi
];
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath buildInputs}:/run/opengl-driver/lib";
RUST_BACKTRACE=1;
};

Expand Down