Skip to content

Commit b05d865

Browse files
authored
Merge pull request #68 from togglebyte/dev
Bugfix for canvas wrap-around
2 parents 86a9849 + 0567086 commit b05d865

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

anathema-backend/src/tui/screen.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::io::{Result, Write};
33
use anathema_geometry::{Pos, Size};
44
use anathema_widgets::paint::CellAttributes;
55
use anathema_widgets::WidgetRenderer;
6-
use crossterm::event::{DisableMouseCapture, EnableMouseCapture};
6+
use crossterm::event::EnableMouseCapture;
77
use crossterm::terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen};
88
use crossterm::{cursor, ExecutableCommand, QueueableCommand};
99

@@ -131,7 +131,7 @@ impl Screen {
131131
disable_raw_mode()?;
132132
output.execute(LeaveAlternateScreen)?;
133133
#[cfg(not(target_os = "windows"))]
134-
output.execute(DisableMouseCapture)?;
134+
output.execute(crossterm::event::DisableMouseCapture)?;
135135
output.execute(cursor::Show)?;
136136
Ok(())
137137
}

anathema-default-widgets/src/canvas.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ impl Buffer {
3030
fn put(&mut self, c: char, style: Style, pos: impl Into<LocalPos>) {
3131
let pos = pos.into();
3232

33-
let index = pos.to_index(self.size.width);
34-
if index >= self.positions.len() {
35-
return;
33+
if pos.x as usize >= self.size.width || pos.y as usize >= self.size.height {
34+
return
3635
}
36+
let index = pos.to_index(self.size.width);
3737

3838
let mut cell = Cell::Occupied(c, style);
3939
std::mem::swap(&mut self.positions[index], &mut cell);

anathema-templates/src/variables.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::collections::HashMap;
22
use std::rc::Rc;
33

4+
#[cfg(not(target_os = "windows"))]
45
use anathema_debug::DebugWriter;
56
use anathema_store::slab::Slab;
67

@@ -370,12 +371,14 @@ impl From<Variables> for HashMap<Rc<str>, Expression> {
370371
}
371372
}
372373

374+
#[cfg(not(target_os = "windows"))]
373375
pub struct ScopeDebug<'a> {
374376
level: usize,
375377
scope: &'a Scope,
376378
store: &'a Slab<VarId, Expression>,
377379
}
378380

381+
#[cfg(not(target_os = "windows"))]
379382
impl DebugWriter for ScopeDebug<'_> {
380383
fn write(&mut self, output: &mut impl std::fmt::Write) -> std::fmt::Result {
381384
let indent = " ".repeat(self.level * 4);
@@ -404,8 +407,10 @@ impl DebugWriter for ScopeDebug<'_> {
404407
}
405408
}
406409

410+
#[cfg(not(target_os = "windows"))]
407411
pub struct VariablesDebug<'a>(pub(crate) &'a Variables);
408412

413+
#[cfg(not(target_os = "windows"))]
409414
impl DebugWriter for VariablesDebug<'_> {
410415
fn write(&mut self, output: &mut impl std::fmt::Write) -> std::fmt::Result {
411416
ScopeDebug {

0 commit comments

Comments
 (0)