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

Simplify geometry stuff #60

Closed
wants to merge 3 commits into from
Closed

Simplify geometry stuff #60

wants to merge 3 commits into from

Conversation

khs26
Copy link
Contributor

@khs26 khs26 commented Nov 19, 2020

Planning to simplify some of the logic around drawing panes and add some geometry helper functionality.

Comment on lines +5 to +15
fn _debug_log_to_file(message: String) {
use std::fs::OpenOptions;
use std::io::prelude::*;
let mut file = OpenOptions::new()
.append(true)
.create(true)
.open("/tmp/mosaic-log.txt")
.unwrap();
file.write_all(message.as_bytes()).unwrap();
file.write_all("\n".as_bytes()).unwrap();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a terrible enough person to leave this in - will pick up the logging functionality

}
}

#[derive(PartialEq, Eq, Hash, Debug)]
pub struct Coordinates {
pub struct ScreenCanvas {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thinking here was potentially to have a more generic type for "Rectangle that can contain other rectangles and knows some stuff about what needs to be drawn". This may already be covered by terminal_pane or similar, I'm not sure

columns: usize,
rows: usize,
boundary_characters: HashMap<Coordinates, BoundaryType>,
borders: HashMap<EdgeType, usize>,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should probably also have a children: Box<Vec<ScreenCanvas>> or similar too

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like everything about this PR except this...
Most multiplexers keep data in this way, and while it's very comfortable for us developers it creates some issues for the users. For example, if we want to resize a pane outside of its parent. This can happen for example where:

  • we have 4 rectangles on screen (by splitting horizontally and then splitting each one of the halves vertically)
  • we resize the bottom-right pane up
  • we then resize it back down to where it was
  • we resize the same pane left

To my knowledge, we're the only multiplexer that supports this. Every other multiplexer would drag the pane's sibling with it in at least one of these directions. And I think it's because they keep a hierarchical map of the panes.

@imsnif
Copy link
Member

imsnif commented Nov 21, 2020

Just leaving a note saying I haven't forgotten this and will take a closer look sometime this week

@khs26
Copy link
Contributor Author

khs26 commented Nov 21, 2020

@imsnif it's very much not ready yet - I've been raising draft PRs early so that people can get a chance to share input. Will convert them to full reviews when ready

@imsnif
Copy link
Member

imsnif commented Nov 21, 2020

I've been raising draft PRs early so that people can get a chance to share input.

For sure, that's what I was talking about :)

@khs26 khs26 marked this pull request as ready for review May 1, 2021 16:43
@khs26 khs26 closed this May 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants