progress toward fixing render bug

macos-click-through
keith 4 years ago
parent 5e32a7ad7b
commit a7d82fb7a1

@ -36,6 +36,8 @@ pub struct CursorMode {
#[derive(Clone, PartialEq)]
pub struct Cursor {
pub position: (f64, f64),
pub grid_position: (u64, u64),
pub parent_window_id: u64,
pub shape: CursorShape,
pub cell_percentage: Option<f32>,
pub blinkwait: Option<u64>,
@ -51,6 +53,8 @@ impl Cursor {
pub fn new() -> Cursor {
Cursor {
position: (0.0, 0.0),
grid_position: (0, 0),
parent_window_id: 0,
shape: CursorShape::Block,
style: None,
cell_percentage: None,

@ -110,7 +110,6 @@ impl Editor {
if let Some(cursor_mode) = self.mode_list.get(mode_index as usize) {
self.cursor.change_mode(cursor_mode, &self.defined_styles);
self.current_mode = mode;
self.draw_command_sender.send(DrawCommand::UpdateCursor(self.cursor.clone())).ok();
}
}
RedrawEvent::MouseOn => {
@ -122,15 +121,14 @@ impl Editor {
RedrawEvent::BusyStart => {
trace!("Cursor off");
self.cursor.enabled = false;
self.draw_command_sender.send(DrawCommand::UpdateCursor(self.cursor.clone())).ok();
}
RedrawEvent::BusyStop => {
trace!("Cursor on");
self.cursor.enabled = true;
self.draw_command_sender.send(DrawCommand::UpdateCursor(self.cursor.clone())).ok();
}
RedrawEvent::Flush => {
trace!("Image flushed");
self.send_cursor_info();
REDRAW_SCHEDULER.queue_next_frame();
}
RedrawEvent::DefaultColorsSet { colors } => {
@ -349,11 +347,17 @@ impl Editor {
}
fn set_cursor_position(&mut self, grid: u64, grid_left: u64, grid_top: u64) {
match self.get_window_top_left(grid) {
self.cursor.parent_window_id = grid;
self.cursor.grid_position = (grid_left, grid_top);
}
fn send_cursor_info(&mut self) {
let (grid_left, grid_top) = self.cursor.grid_position;
match self.get_window_top_left(self.cursor.parent_window_id) {
Some((window_left, window_top)) => {
self.cursor.position = (window_left + grid_left as f64, window_top + grid_top as f64);
if let Some(window) = self.windows.get(&grid) {
if let Some(window) = self.windows.get(&self.cursor.parent_window_id) {
let (character, double_width) = window.get_cursor_character(grid_left, grid_top);
self.cursor.character = character;
self.cursor.double_width = double_width;

@ -173,7 +173,7 @@ impl Window {
// Insert the contents of the cell into the grid.
if text.is_empty() {
if let Some(cell) = self.grid.get_cell_mut(*column_pos, row_index) {
*cell = Some(("".to_string(), style.clone()));
*cell = Some((" ".to_string(), style.clone()));
}
*column_pos += 1;
} else {
@ -184,6 +184,10 @@ impl Window {
}
*column_pos += text.graphemes(true).count() as u64;
}
if let Some(style) = style {
*previous_style = Some(style);
}
}
fn send_draw_command(
@ -215,7 +219,7 @@ impl Window {
let mut draw_command_end_index = current_start;
for possible_end_index in draw_command_start_index..(self.grid.width - 1) {
for possible_end_index in draw_command_start_index..self.grid.width {
if let Some((_, possible_end_style)) = &row[possible_end_index as usize] {
if style == possible_end_style {
draw_command_end_index = possible_end_index;
@ -227,7 +231,7 @@ impl Window {
// Build up the actual text to be rendered including the contiguously styled bits.
let mut text = String::new();
for x in draw_command_start_index..draw_command_end_index+1 {
for x in draw_command_start_index..draw_command_end_index {
let (character, _) = row[x as usize].as_ref().unwrap();
text.push_str(character);
}
@ -235,7 +239,7 @@ impl Window {
// Send a window draw command to the current window.
self.send_command(WindowDrawCommand::Cell {
text,
cell_width: draw_command_end_index - draw_command_start_index,
cell_width: draw_command_end_index - draw_command_start_index + 1,
window_left: draw_command_start_index,
window_top: row_index,
style: style.clone()
@ -265,7 +269,8 @@ impl Window {
}
let mut current_start = column_start;
while current_start < self.grid.width - 1 {
while current_start < column_pos {
println!("{}", current_start);
if let Some(next_start) = self.send_draw_command(row, column_start, current_start) {
current_start = next_start;
} else {

@ -219,7 +219,7 @@ impl RenderedWindow {
} => {
let grid_position = (window_left, window_top);
println!("{} left: {} top: {}", text, window_left, window_top);
// println!("{} left: {} top: {}", text, window_left, window_top);
{
let mut background_canvas = self.background_surface.canvas();

Loading…
Cancel
Save