mirror of
https://github.com/TaKO8Ki/gobang
synced 2024-11-11 07:10:31 +00:00
change left_chunk_percentage to left_main_chunk_percentage
This commit is contained in:
parent
101ea7336d
commit
0a27e553eb
25
src/app.rs
25
src/app.rs
@ -34,7 +34,7 @@ pub struct App {
|
|||||||
databases: DatabasesComponent,
|
databases: DatabasesComponent,
|
||||||
connections: ConnectionsComponent,
|
connections: ConnectionsComponent,
|
||||||
pool: Option<Box<dyn Pool>>,
|
pool: Option<Box<dyn Pool>>,
|
||||||
left_chunk_percentage: u16,
|
left_main_chunk_percentage: u16,
|
||||||
pub config: Config,
|
pub config: Config,
|
||||||
pub error: ErrorComponent,
|
pub error: ErrorComponent,
|
||||||
}
|
}
|
||||||
@ -55,7 +55,7 @@ impl App {
|
|||||||
error: ErrorComponent::new(config.key_config),
|
error: ErrorComponent::new(config.key_config),
|
||||||
focus: Focus::ConnectionList,
|
focus: Focus::ConnectionList,
|
||||||
pool: None,
|
pool: None,
|
||||||
left_chunk_percentage: 15,
|
left_main_chunk_percentage: 15,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,8 +76,8 @@ impl App {
|
|||||||
let main_chunks = Layout::default()
|
let main_chunks = Layout::default()
|
||||||
.direction(Direction::Horizontal)
|
.direction(Direction::Horizontal)
|
||||||
.constraints([
|
.constraints([
|
||||||
Constraint::Percentage(self.left_chunk_percentage),
|
Constraint::Percentage(self.left_main_chunk_percentage),
|
||||||
Constraint::Percentage((100_u16).saturating_sub(self.left_chunk_percentage)),
|
Constraint::Percentage((100_u16).saturating_sub(self.left_main_chunk_percentage)),
|
||||||
])
|
])
|
||||||
.split(f.size());
|
.split(f.size());
|
||||||
|
|
||||||
@ -455,7 +455,8 @@ impl App {
|
|||||||
.key_config
|
.key_config
|
||||||
.extend_or_shorten_widget_width_to_left
|
.extend_or_shorten_widget_width_to_left
|
||||||
{
|
{
|
||||||
self.left_chunk_percentage = self.left_chunk_percentage.saturating_sub(5).max(15);
|
self.left_main_chunk_percentage =
|
||||||
|
self.left_main_chunk_percentage.saturating_sub(5).max(15);
|
||||||
return Ok(EventState::Consumed);
|
return Ok(EventState::Consumed);
|
||||||
} else if key
|
} else if key
|
||||||
== self
|
== self
|
||||||
@ -463,7 +464,7 @@ impl App {
|
|||||||
.key_config
|
.key_config
|
||||||
.extend_or_shorten_widget_width_to_right
|
.extend_or_shorten_widget_width_to_right
|
||||||
{
|
{
|
||||||
self.left_chunk_percentage = (self.left_chunk_percentage + 5).min(70);
|
self.left_main_chunk_percentage = (self.left_main_chunk_percentage + 5).min(70);
|
||||||
return Ok(EventState::Consumed);
|
return Ok(EventState::Consumed);
|
||||||
}
|
}
|
||||||
Ok(EventState::NotConsumed)
|
Ok(EventState::NotConsumed)
|
||||||
@ -512,26 +513,26 @@ mod test {
|
|||||||
app.extend_or_shorten_widget_width(Key::Char('>')).unwrap(),
|
app.extend_or_shorten_widget_width(Key::Char('>')).unwrap(),
|
||||||
EventState::Consumed
|
EventState::Consumed
|
||||||
);
|
);
|
||||||
assert_eq!(app.left_chunk_percentage, 20);
|
assert_eq!(app.left_main_chunk_percentage, 20);
|
||||||
|
|
||||||
app.left_chunk_percentage = 70;
|
app.left_main_chunk_percentage = 70;
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
app.extend_or_shorten_widget_width(Key::Char('>')).unwrap(),
|
app.extend_or_shorten_widget_width(Key::Char('>')).unwrap(),
|
||||||
EventState::Consumed
|
EventState::Consumed
|
||||||
);
|
);
|
||||||
assert_eq!(app.left_chunk_percentage, 70);
|
assert_eq!(app.left_main_chunk_percentage, 70);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
app.extend_or_shorten_widget_width(Key::Char('<')).unwrap(),
|
app.extend_or_shorten_widget_width(Key::Char('<')).unwrap(),
|
||||||
EventState::Consumed
|
EventState::Consumed
|
||||||
);
|
);
|
||||||
assert_eq!(app.left_chunk_percentage, 65);
|
assert_eq!(app.left_main_chunk_percentage, 65);
|
||||||
|
|
||||||
app.left_chunk_percentage = 15;
|
app.left_main_chunk_percentage = 15;
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
app.extend_or_shorten_widget_width(Key::Char('<')).unwrap(),
|
app.extend_or_shorten_widget_width(Key::Char('<')).unwrap(),
|
||||||
EventState::Consumed
|
EventState::Consumed
|
||||||
);
|
);
|
||||||
assert_eq!(app.left_chunk_percentage, 15);
|
assert_eq!(app.left_main_chunk_percentage, 15);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user