|
|
@ -238,16 +238,14 @@ impl Editor {
|
|
|
|
fn resize_window(&mut self, grid: u64, width: u64, height: u64) {
|
|
|
|
fn resize_window(&mut self, grid: u64, width: u64, height: u64) {
|
|
|
|
trace!("editor resize {}", grid);
|
|
|
|
trace!("editor resize {}", grid);
|
|
|
|
if let Some(window) = self.windows.get_mut(&grid) {
|
|
|
|
if let Some(window) = self.windows.get_mut(&grid) {
|
|
|
|
window.resize(width, height);
|
|
|
|
window.resize((width, height));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
let window = Window::new(
|
|
|
|
let window = Window::new(
|
|
|
|
grid,
|
|
|
|
grid,
|
|
|
|
WindowType::Editor,
|
|
|
|
WindowType::Editor,
|
|
|
|
width,
|
|
|
|
|
|
|
|
height,
|
|
|
|
|
|
|
|
None,
|
|
|
|
None,
|
|
|
|
0.0,
|
|
|
|
(0.0, 0.0),
|
|
|
|
0.0,
|
|
|
|
(width, height),
|
|
|
|
self.draw_command_batcher.clone(),
|
|
|
|
self.draw_command_batcher.clone(),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
self.windows.insert(grid, window);
|
|
|
|
self.windows.insert(grid, window);
|
|
|
@ -263,17 +261,15 @@ impl Editor {
|
|
|
|
height: u64,
|
|
|
|
height: u64,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
if let Some(window) = self.windows.get_mut(&grid) {
|
|
|
|
if let Some(window) = self.windows.get_mut(&grid) {
|
|
|
|
window.position(width, height, None, start_left as f64, start_top as f64);
|
|
|
|
window.position(None, (width, height), (start_left as f64, start_top as f64));
|
|
|
|
window.show();
|
|
|
|
window.show();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
let new_window = Window::new(
|
|
|
|
let new_window = Window::new(
|
|
|
|
grid,
|
|
|
|
grid,
|
|
|
|
WindowType::Editor,
|
|
|
|
WindowType::Editor,
|
|
|
|
width,
|
|
|
|
|
|
|
|
height,
|
|
|
|
|
|
|
|
None,
|
|
|
|
None,
|
|
|
|
start_left as f64,
|
|
|
|
(start_left as f64, start_top as f64),
|
|
|
|
start_top as f64,
|
|
|
|
(width, height),
|
|
|
|
self.draw_command_batcher.clone(),
|
|
|
|
self.draw_command_batcher.clone(),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
self.windows.insert(grid, new_window);
|
|
|
|
self.windows.insert(grid, new_window);
|
|
|
@ -302,8 +298,6 @@ impl Editor {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
window.position(
|
|
|
|
window.position(
|
|
|
|
width,
|
|
|
|
|
|
|
|
height,
|
|
|
|
|
|
|
|
Some(AnchorInfo {
|
|
|
|
Some(AnchorInfo {
|
|
|
|
anchor_grid_id: anchor_grid,
|
|
|
|
anchor_grid_id: anchor_grid,
|
|
|
|
anchor_type,
|
|
|
|
anchor_type,
|
|
|
@ -311,8 +305,8 @@ impl Editor {
|
|
|
|
anchor_top,
|
|
|
|
anchor_top,
|
|
|
|
sort_order: sort_order.unwrap_or(grid),
|
|
|
|
sort_order: sort_order.unwrap_or(grid),
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
modified_left,
|
|
|
|
(width, height),
|
|
|
|
modified_top,
|
|
|
|
(modified_left, modified_top),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
window.show();
|
|
|
|
window.show();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -338,22 +332,18 @@ impl Editor {
|
|
|
|
if let Some(window) = self.windows.get_mut(&grid) {
|
|
|
|
if let Some(window) = self.windows.get_mut(&grid) {
|
|
|
|
window.window_type = WindowType::Message;
|
|
|
|
window.window_type = WindowType::Message;
|
|
|
|
window.position(
|
|
|
|
window.position(
|
|
|
|
parent_width,
|
|
|
|
|
|
|
|
window.get_height(),
|
|
|
|
|
|
|
|
Some(anchor_info),
|
|
|
|
Some(anchor_info),
|
|
|
|
0.0,
|
|
|
|
(parent_width, window.get_height()),
|
|
|
|
grid_top as f64,
|
|
|
|
(0.0, grid_top as f64),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
window.show();
|
|
|
|
window.show();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
let new_window = Window::new(
|
|
|
|
let new_window = Window::new(
|
|
|
|
grid,
|
|
|
|
grid,
|
|
|
|
WindowType::Message,
|
|
|
|
WindowType::Message,
|
|
|
|
parent_width,
|
|
|
|
|
|
|
|
1,
|
|
|
|
|
|
|
|
Some(anchor_info),
|
|
|
|
Some(anchor_info),
|
|
|
|
0.0,
|
|
|
|
(0.0, grid_top as f64),
|
|
|
|
grid_top as f64,
|
|
|
|
(parent_width, 1),
|
|
|
|
self.draw_command_batcher.clone(),
|
|
|
|
self.draw_command_batcher.clone(),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
self.windows.insert(grid, new_window);
|
|
|
|
self.windows.insert(grid, new_window);
|
|
|
@ -387,26 +377,27 @@ impl Editor {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn set_cursor_position(&mut self, grid: u64, grid_left: u64, grid_top: u64) {
|
|
|
|
fn set_cursor_position(&mut self, grid: u64, grid_left: u64, grid_top: u64) {
|
|
|
|
match self.windows.get(&grid) {
|
|
|
|
if let Some(Window {
|
|
|
|
Some(Window { window_type: WindowType::Message, .. }) => {
|
|
|
|
window_type: WindowType::Message,
|
|
|
|
// When the user presses ":" to type a command, the cursor is sent to the gutter
|
|
|
|
..
|
|
|
|
// in position 1 (right after the ":"). In all other cases, we want to skip
|
|
|
|
}) = self.windows.get(&grid)
|
|
|
|
// positioning to avoid confusing movements.
|
|
|
|
{
|
|
|
|
let intentional = grid_left == 1;
|
|
|
|
// When the user presses ":" to type a command, the cursor is sent to the gutter
|
|
|
|
// If the cursor was already in this message, we can still move within it.
|
|
|
|
// in position 1 (right after the ":"). In all other cases, we want to skip
|
|
|
|
let already_there = self.cursor.parent_window_id == grid;
|
|
|
|
// positioning to avoid confusing movements.
|
|
|
|
|
|
|
|
let intentional = grid_left == 1;
|
|
|
|
|
|
|
|
// If the cursor was already in this message, we can still move within it.
|
|
|
|
|
|
|
|
let already_there = self.cursor.parent_window_id == grid;
|
|
|
|
|
|
|
|
|
|
|
|
if !intentional && !already_there {
|
|
|
|
if !intentional && !already_there {
|
|
|
|
trace!(
|
|
|
|
trace!(
|
|
|
|
"Cursor unexpectedly sent to message buffer {} ({}, {})",
|
|
|
|
"Cursor unexpectedly sent to message buffer {} ({}, {})",
|
|
|
|
grid,
|
|
|
|
grid,
|
|
|
|
grid_left,
|
|
|
|
grid_left,
|
|
|
|
grid_top
|
|
|
|
grid_top
|
|
|
|
);
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_ => {}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
self.cursor.parent_window_id = grid;
|
|
|
|
self.cursor.parent_window_id = grid;
|
|
|
|